My site until now didn’t indicate very well in which language my postings are written. I write here mostly in English, but also sometimes use two other languages, Dutch and German.

My friend Peter pointed out to me that if he reads Franks blog in his feedreader and clicks on the link his browser automatically translates it into English. As Peter suggested, this is most likely because Frank’s site declares Dutch as its language, and mine declares English. I decided to look into it and see if I could change that.

The language declaration Peter pointed to is the very first statement in the source code for this page:

Frank’s site in the same space says his site is in Dutch.

Frank also publishes in English sometimes, and then the language setting would be factually incorrect. Peter just wouldn’t notice as he wouldn’t attempt to translate English, his native language.

My company’s website in contrast declares three languages, by giving a different url for English and German, next to the regular Dutch. However in this case it is about the same or similar pieces of content made available in different languages. Which is not the same use case as my blog, where there is different content in different languages.

I concluded I needed to figure out how to a) for the category archive pages for Dutch and German postings declare the right language (because I mark any posting not in English with a separate category corresponding to its language), and b) for individual postings not in English declare the right language.

First I looked at what the W3C says about indicating content languages. It turns out Frank and I both do it right, the html statement is the place to declare the default language of a website. In Frank’s case Dutch, in my case English. The W3C goes on to say that any other languages should be indicated in the location where they are used. This e.g. would allow me to indicate the correct language even if I use a non-English phrase in the middle of an otherwise English text, hetgeen een mooie oplossing is voor automatische vertaalsoftware. Which looks like this in html:

This means that what I needed to do was for the category archive pages for Dutch and German, as well as for individual postings, find the right spot in the source of a page to declare the correct language. I did this in the WordPress Theme I am using, or rather in the child theme (which allows you to specify any deviations from the original theme, while keeping the rest of the theme as it was).

For both the Dutch and German category pages I created separate templates, called category-nederlands.php and category-deutsch.php, which corresponds with the name of the category in my WordPress instance. At the top of those pages I added a language indicator where the main part of the page starts.

For individual blogposts it is a bit more difficult, as you need to be able to determine first if a posting is in another language than English. I adapted the single.php template, which renders individual postings. There I added a line of code to see if the posting is in Dutch or German, by checking if it is in the corresponding category.

This results in either adding lang=”nl-nl” or lang=”de-de” to postings in those languages, in the same location as for the category archive pages shown above.

Hopefully this now allows browsers to correctly detect the language of content on my site.
I’m not entirely done yet. Because in some overviews, like the front page, individual postings that are not in English are not rightly marked with the correct language yet. Only if you go to that posting itself, will the language be correctly set. But this can be solved in a similar way, I assume. [UPDATE 2019-10-14] I’ve also edited the index.php and category.php templates to check if a posting is in the Dutch or German language category, and add a language declaration using a <div lang="nl-nl"> around the posting. For the index.php I do that only for the home page. This works, but as far as I can tell e.g. Google Translate for ‘detect language’ only checks the default language of a page. As I am not here to facilitate Google, I am currently satisfied that I at least do now provide clear meta-data about the language of postings I publish.[/UPDATE]
A final step I’d like to add is automatically insert machine translation links into my rss feed items, although I’m still not entirely sure that would be useful.

I use the WP Plugin Post Kinds here, which lets me blog things like Replies, Likes, etc. This plugin has a setting that determines the order in which my own remarks with a Reply or Like and the thing I am replying to or liking are shown.

The default order is [the thing I respond to] [my response], but here in this blog I have changed that, because I like to have my own response first. This ensures for instance that my own words, and not someone else’s get posted to Twitter if I share my post directly to Twitter.

This setting does not change the way the same blogpost gets added to the RSS feed. This means that my regular readers do not get the content of a posting as I intend it, which is in the same order as a website visitor.
In addition it causes anything that consumes my feed, such as my Micro.blog account to show the post I am responding to first (someone else’s words) and not my remarks. Below in three images is how that looks in practice:

The old version: the order is as I want it on the site.

The old version: the order is reversed for the same item in my feed

Micro.blog posts from my feed, and therefore shows not my words first but the words I’m reacting to, which makes them appear as if they are my words

I figured out where in the plugin files (in class-kind-view.php) the feed gets created and how it is different from how the posting is created for the site. Then I added the conditional code from the latter to the former. This works on my site, as shown by the following three images:

Testing the new code: on my site the item is in the right order

In the RSS feed, the content of the item is now in the right order too

And the right order now shows up in Micro.blog, showing my own words first

Then I tried to let the creator of the WP Plugin know I made this change, through a Pull Request on GitHub. I’v never done this before. It’s basically a message ‘I changed this file here’ which the original creator can then adopt in the original code. Making that message meant engaging with concepts such as forks, branches, commits and then the Pull Request. I think I pulled if off, but I will only know when David Shanske, who makes Post Kinds indeed incorporates it in the plugin.

Hoping I’ve submitted my first ever PR the right way

I’ve added a plugin, Mastodon Autopost, to crosspost from this blog to my Mastodon instance.
This won’t bring back any reactions to this blog, unlike Twitter reactions which do get back to this blog through Webmention. For that I would need to use Bridgy Fed. However that has as a disadvantage that it would turn my blog into a separate ActivityPub account, an activitypub user in its own right.

For now I’d rather have a separate Mastodon account (on my personal instance). Not everything I post on my blog I want to post to Mastodon, and not everything I post on Mastodon I want to have in my blog (e.g. responses to or reposts of others). I can definitely see me using this blog as the one and only hub for my online communications, but for that to work, I want to be able to keep ephemeral postings outside my regular site and my rss feeds, and more importantly be able to determine intended audiences per posting. Another requirement is that I can post tweets about a blogpost without that tweet being a separate blogpost (now I use the post excerpt for that and send it to twitter)

Currently I have my Mastodon (and my first Twitter account) set to me needing to approve every follower. My audience for a message is somewhat known to me that way, and I can shape a message accordingly. We all talk differently to different people and have conversations in different settings and contexts. This is true for online conversations just as much as for offline conversations. My microblog account does post everything from my blog but I also interact there independently from my blog.

With this plugin, for each posting I can determine if it is cross posted to Mastodon. I already had a similar setting for Twitter (and Flickr, which I don’t use). See the images.

[UPDATE]
It works as intended. I set the excerpt of this posting to “If all works as intended, this blogpost should show up in my Mastodon instance #wordpress #activitypub”, and set the plugin to post title, excerpt and URL.


[/UPDATE]

I have a ‘recent posts’ and ‘recent comments’ section in the sidebar. This seemed to create problems with the processing of webmentions, specifically with Aaron Parecki’s Xray library for grabbing structured info from any URL. It would find an apparently improperly micro-formatted link in the sidebar and take that as the URL of the posting referred to. This would create faulty likes on other people’s sites, which then would send webmentions to the wrong postings.

As recent posts and recent comments are only a navigational aid when you’re looking at things like the front page, search results and archive pages, I looked into if I can show them on those pages only. Because if those sections aren’t present on the pages of individual postings, they cannot cause problems when parsed for structure. This being a WordPress site, of course there’s a plugin for it, Widget Context. I installed it, removed the offending widgets from individual pages, and it looks like the problem has been solved.