Jira add-on page Internationalization

We have tried internationalizing our Jira cloud add-on based on this documentation, we got the add-on name changed in side bar as specified. But, how can I apply the internationalization within my add-on page.

Is there any default methods in Jira to implement this? Or, what is the recommended way to internationalize add-on page?

Hi @rajagopal,

Since the content on your app’s page is loaded inside an iframe, any content rendered inside the iframe should be internationalized by your app itself, there is no built in support for this. You can use the loc context parameter to get the current user’s locale and respond appropriately.

Hi @dmeyer,

Thanks, your solution worked for me.

Hi @dmeyer,

Now, accessing the loc in context parameters are deprecated. So, what is the recommended way to access it? We are using the hbs files which is processed on server side but the REST API could be done only on client side. How do we localize the content of hbs?

You could do a Rest API call to Jira/Confluence /rest/api/3/myself on the server by generating a signed JWT yourself using the sharedSecret you received in the post install (if you use ACE, this is done automatically for you, otherwise you will need to calculate qsh and add the calling user accountId in the sub which you can get from the JWT passed in the query string).

Probably best to store the value either with your own user object in the database or in an httpOnly cookie to avoid having to call the API for each request.

1 Like

@remie, Thanks for the quick response. Yeah we are using the ACE. We don’t see any documentation to give the request to jira directly in server side. Can you please give us an example of how do we perform this request in server side(ACE)?

I don’t use ACE myself, but you should be able to get this working if you look at the How to send a signed HTTP request from the iframe back to the add-on service section of the ACE readme, and specifically the section on httpClient.asUserByAccountId.

From the docs:

var httpClient = addon.httpClient(req);
httpClient.asUserByAccountId('ebcab857-c769-4fbd-8ad6-469510a43b87').get('/rest/api/latest/myself', function(err, res, body) {
  ...
});

Now as you see the accountId is hardcoded in this example, but this should be available as context variable (userAccountId) if you are using the JWT authentication middleware (see “How to secure a route with JWT”)

1 Like

Or use this: Getting user details

1 Like

Thank you @remie …!!