Testing plugin in multiple languages

Hi Guys,

I’m trying to add another language to my add-on which is already internationalised. However, I can’t seem to get it to work consistently. After starting the server via atlas-run and changing the language in the system tab, sometimes it works and some other times it doesn’t. I can’t seem to have my add-on switch language when I change the system language. Sometimes it works after a restart and sometimes it doesn’t.

I added a new properties file with the naming _fr_FR.properties and added it to the atlassian-plugin.xml file.

Did I miss anything? I even tried to clean up all traces of my add-on in the target folder.

Any hint would be appreciated.

Thanks!

Ok, I thought that I had found the issue by looking at this Internationalization link. Turns out that this link also has some errors in it. It mentions that this line in the atlassian-plugin.xml file should only have the directory names in the location attribute.

<resource type="i18n" name="myaddon" location="com.example"/>

Well, you need to add the file name as well which leads to:

<resource type="i18n" name="myaddon" location="com.example.myaddon"/>

When the name is not there, the file is not loaded. Still, if I put in my directory the files:

myaddon.properties
myaddon_en_US.properties
myaddon_fr_FR.properties

It recognizes the default file and uses it for any langage except for English (US) which use the _en_US file. However when I switch to French (France), it doesn’t use the _fr_FR file and use the default property file instead.

Do we need to add more i18n entries in the atlassian-plugin.xml file? I don’t think so but tried it as well but still not working.

Any one has a plugin working with multiple language files who could give me pointers?

Hi @yvesriel,

here is the configuration from one of our plugins. In the atlassian-plugin.xml file we have

<resource type="i18n" name="i18n" location="jira2factorauth"/>

And directly in the resource folder, we have our localization files:

jira2factorauth.properties
jira2factorauth_de_DE.properties
jira2factorauth_ru_RU.properties

So it almost looks like the same you have, except we ponly reference the name in the location attribute.

However when I switch to French (France), it doesn’t use the frFR file and use the default property file instead.

I guess that stopping and cleaning the plugin view atlas-clean will resolve the problem.

Thanks, however, I tried that many times :frowning:

Thanks for sharing!

I even tried with the name “i18n” too but without success. I will try to move my files to the root of the plugin and only reference the name to see if it makes a difference.

@yvesriel Perhaps you’re assuming that “com.example.myaddon” maps to “com/example/myaddon.properties”? Which it wouldn’t. Need “/” as your path separator.

So here’s a working example:
<resource name="App Internationalization" type="i18n" location="i18n/app"/>

with files from package root:

i18n/app.properties
i18n/app_de.properties
etc.

Finally found the problem! Thanks to @alexander.kueken example files, I knew that everything was setup properly but it still failed to load the language. Turns out that passing the property file in native2ascii to transform non ascii characters into Unicode-Encoded Ascii characters converted properly but I somehow managed to delete by mistake one character of the unicode string.

So, my French file had this error and when trying to load the translation, jira failed and fell back to the default property file thus giving me the impression that the language was not loading. And there was no errors/message in the log file :frowning:

So, after correcting the unicode typo, the language is now loading properly.

Thank you all for your help!

Hi @davidg,

I tried it as well at some point. It also works with dots (.) instead of backslash (/). Actually, my location attribute is now using dots and it finds the property files.

Thanks for mentioning it!