Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

AJS.I18n.getText issue

Leon Wright November 14, 2013

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!

 

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Leon Wright December 4, 2013

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)

4 votes
Ulrich Kuhnhardt [Comalatech]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2014

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

Leon Wright March 24, 2014

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.

TakashiI September 25, 2014

I have same problem with developing Confluence plugin. I also try transformation, but it was useless. Thanks Ulrich, your lazy-load method works well.

0 votes
Hans de Groot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 14, 2013

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 '__'

 

 

 

Leon Wright November 18, 2013

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.

TAGS
AUG Leaders

Atlassian Community Events