Hi,
I am working on a Confluence theme and have to do some localization on a few UI elements. I was wondering if anyone knows how Confluence handles this in their default theme. I have a browser setup with the default langauge as Japanese and when I visit the site, the default confluence UI is translated to Japanese. I would like to know how they do this and if it's better than what I am doing. I am just writing Javascript like so:
AJS.toInit(function(){
var browserLang = navigator.language || navigator.userLanguage;
if(browserLang =="ja"){
AJS.$('#some-button').text("japanese text here");
AJS.$('#some-other-button').text("japanese text here");\
etc..
}
}
Even though this seems to work fine, maybe there is a much better way of handling things like this. I wondering if Confluence does this the same way or if they just load different themes depending on browser langauge or ?
Thanks
Community moderators have prevented the ability to post new answers.
Hi,
I don't know in themes, but in plugin development, internationalisation is done like this in js:
AJS.I18n.getText("properties.key");
For that, you need in your atlassian-plugin.xml
<web-resource name="Whatever Resources" key="whateverResources"> <transformation extension="js"> <transformer key="jsI18n"/> </transformation> ...
You can find more information here https://developer.atlassian.com/display/AUI/AJS.I18n.getText
Hope this helps!
Gorka
As Gorka stated, you'll need to specify in your xml that you'd like to add the i18n transformer to your resources. When done you can access your properties through js with
AJS.I18n.getText
Here's more on how you write your properties files, you'll find file names and locations needed for you to access the properties here: https://developer.atlassian.com/display/DOCS/Internationalising+your+plugin
And here is some more info on how Confluence names their properties files:
https://developer.atlassian.com/display/CONFDEV/I18N+Architecture
Dennis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Alex,
I'm not an expert developer but I know a few things regarding how Confluence handles the default languages.
Instead of doing that what happens if you install the japanse language pack and then switch the default language to japanes as per below two guides?
https://confluence.atlassian.com/display/DOC/Installing+a+Language+Pack
https://confluence.atlassian.com/display/DOC/Choosing+a+Default+Language
Hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thats for confluence built in UI. I was just wondering in general how they handle localization, like do they use javascript, vm files, or something else to show UI elements in different languages. I added some new UI elements to my theme so confluence won't translate those automatically which is why I am doing it using javascript. Just wondering if there is a better way.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry buddy, in that case I really dont know :(.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.