All,
Tearing my hair out and don't appear to be getting anywhere with one of my final tasks in internatinalising one of our internal plugins. After following this guide:
https://developer.atlassian.com/display/AUI/AJS.I18n.getText
Now we have a i18n.properties file, which is working for a bunch of our Velocity templates that contains:
common.qa.riskscore.low=Low
The JS resource has the transform defined:
<web-resource key="risklevels" i18n-name-key="web-resource.keyname.risklevels" > <transformation extension="js"> <transformer key="jsI18n"/> </transformation> <description>This resource is for adding Text descriptions of risk scores</description> <dependency>com.atlassian.auiplugin:ajs</dependency> <dependency>com.atlassian.auiplugin:jquery</dependency> <resource type="download" name="risklevels.js" location="js/risklevels.js" /> <context>jira.create.issue</context> <context>jira.view.issue</context> </web-resource>
And I have defined the variable I wish to use like so:
var low = AJS.I18n.getText("common.qa.riskscore.low");
All I'm getting in the the frontend is:
common.qa.riskscore.low
Now I presume it's doing something, but just can't find the translation. Any pointers or suggestions as to what might be going wrong?
Thanks!
Community moderators have prevented the ability to post new answers.
Language wasn't required for this release, so I left the changes in our internal plugin in a dev branch. Testing in Jira 6.1.4 and everything works as expected.
I was probably hitting some edge case bug, but it works now and I'm happy.
NOTE: It could also be cache related. I note that it does seem to hold onto things a lot longer than other things in the interface. (though I had done browser cache clears + instance restarts during diagnosis)
Leon,
We've come across the same problem. If you don't 'require' the web resource 'risklevels' either via $webResourceManager or #requireResource somewhere in your rendering process and only rely on this resource being injected for the given contexts - the jsI18n transformer won't run.
Solution - Lazy-load your i18n resource
Include AJS.I18n.get("plugin.key") into the JS initialisation phase (AJS.toInit(function(){})) then all missing i18n key:text pairs are loaded via REST. AJS.I18n.getText('common.qa.riskscore.low') will be available.
@Atlassian: Please document this scenario. https://developer.atlassian.com/display/AUI/AJS.I18n.getTextis incomplete
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will have to look into that. I actually made no major changes to my original JS and it worked. There are a few variables that I can't really rule out, including a newer Jira version and caching.
Considering I note the data model has changed that select fields refer to an ID instead of the contents, I would suggest that Atlassian are working on making them multi laanguage. Which will make the custom JS unecessary, so I probably won't get to making any improvements to that code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have same problem with developing Confluence plugin. I also try transformation, but it was useless. Thanks Ulrich, your lazy-load method works well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use an ALL_ALL.xml for my messages.
<messagebundle> <msg name="gadget.title">myTitle</msg> </messagebundle>
And then in the gadget.xml I use:
<Locale messages="__ATLASSIAN_BASE_URL__/download/resources/com-nice-atlassian-jira-gadget-chart/i18n/ALL_ALL.xml" /> <ModulePrefs title="__MSG_gadget.title__" directory_title="test" description="test">
Text will translated if it is surrounded with: '__MSG_' and '__'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do have a method which works, however I'm working towards making the plugin more maintainable and using the avaiable i18n mechanisms makes a lot of sense.
The plugin doesn't have an VM templates, just a handful of JS files, some CSS and the i18n translations.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.