Internationalization for Confluence Cloud

Is there any documentation or solution for internationalizing content on a page using similar methods to I18n.getText() on server? We are not using web items because we are dealing with custom content in our plugin.

I’ve already took a look at:

but, again this overs using web items.

Is there some sort of reference guide using a .properties file or .json file? How do we handle supporting languages for our plugin’s content on cloud? Thanks!

1 Like

Hey, we use a seperate js file that holds all the strings in different languages so you can target each one with, for example, strings[usrLocale].error_upload. usrLocale is a variable that holds a string like ‘en_US’ or another language.

Thanks for the quick reply! We might be able to utilize this a version of this approach. but are you calling it from js or from the soy/hbs templates?

Do you find that the user locale accurately corresponds to the language the user wants? A user in the US might want a Spanish version or a user in India may want an English version. Thank again.

Most of the stuff happens in the routes and hbs just outputs the correct string.
First we get the user locale from /rest/api/3/user?accountId=<user-acc-id>. Cache it if you want to so you don’t have to do so many requests. Then you have to import the file with your localized strings and send both as parameters to your hbs template. Inside the templates, use the lookup helper to get the proper string, which in our case would be something like {{lookup (lookup lang locale) 'update_done'}}.
The downside to this approach is that the same file has to be used somewhere in frontend JS so we also include the strings from the current language into the template as a variable.

As far as accuracy goes, we’ve thoroughly tested it and it’s working as it should because it takes the language that the user set for its profile and instance. So, if a US user chose Spanish as his language, the returned locale is es_ES.

Hope this helps

1 Like

Ah I see…thanks alot!
I wish they had better documentation on this but your post will definitely help me as well as others I’m sure.

Yeah, we haven’t really found any documentation either so this was the easiest approach that we could come up with. I’m sure there are better ideas or even some libraries that might handle this, but for our use case, it’s enough. :slight_smile:

Glad to have helped