Internationalization - Change Publication Language Programatically

I am excited to see the new Internationalization functionality and am hopeful that full multi-lingual support will be available someday.

In the meantime, I am curious if there is a way to use javascript to change the publication language programmatically on a page by page basis vs it just being a global setting?

It’s a pretty big jump from single language to multi language. I ‘snuck in’ the ability to pass portal a language choice recently [and search and comments already have that], which will provide a little support for multi-language.

What’s missing is the ability to handle navigation elements smoothly, and to have the theme translations not always in a single language.

When I get time and funding to work on i18n some more, my next target is an overhaul on theme i18n that is blocking the inclusion of translations in official themes. I think that’s higher priority than multi-language support. (And probably easier, too.) I’ll look to see if there’s a way to pass in a language preference on a page-by-page basis. Maybe it’ll be straightforward? (But I’m not super optimistic.)

The other big thing that’s missing here is the ability to pass a language preference to outgoing newsletters and to outgoing transactional email. [And they’re two separate things.] Presumably, if a user signs up on a German page, with German language portal, they should get a German email with the magic link. But if they sign up on the French page, they should get a French email. That’s unsupported currently. You can get the right language in the portal, but the magic link emails are going to be in the sitewide language, whatever that is.

To your specific question: could you use javascript to change the language of some pages?

Well, yes, sort of. You could change the language set on the html tag easily enough. You could change what language Portal/Comments/Search load in. With slightly more difficulty, you could change the language of the navigation elements (by rewriting them). I’m assuming the body of the post is already in the target language for the page.

If you haven’t already seen it, it’d be worth looking at the Weglot integration for Ghost also. That still doesn’t solve the email language problem, but it would auto-translate your navigation items.

I had a post sitting in my drafts about multi-language support. Here it is:

Thank you so much @Cathy_Sarisky, this is very helpful! Ghost is so close and I may be in touch to talk about that funding!

1 Like