Internationalization approach for Forge Apps?

Does Atlassian suggest an internationalization approach?
(Maybe depending on using UI Kit / Custom UI)

I couldn’t find any hint therefor.

1 Like

I would prefer not to have a suggestion on how to do internationalization if using Custom UI. An approach similar to AJS.Meta would be fine, i.e., providing some context information such that the Custom UI can choose the language correctly. Then your app can make use of e.g. i18next, react-intl, js-lingui… or whatever you want or are already using.

2 Likes

I am using the myself rest endpoint call once my Custom UI initially loads. Then I transfer the locale and timezone into my own React Context so that I have it ready everywhere. Then I can use i18next or custom i18n tools.

const response = await this.api.asUser().requestJira(`/rest/api/3/myself`, DEFAULT_JSON_HEADERS);
//  timeZone: string | undefined;
//  locale: string | undefined;

If it is undefined, I fallback to en_US and some hard coded timezone or UTC.

Maybe Atlassian can suggest a better approach :slight_smile:

4 Likes

Sounds like a valid approach. My only concern is the user experience and number of requests. Imagine that every vendor on every app load calls this endpoint. You would see a lot of requests just to get some static information. As for the user experience: What happens if the request fails? If you fallback to e.g. en_US then this might not be an ideal user experience, especially if the user was working with the same app in a different language before, e.g. de_DE.

I mean it is serverless :smiley: Atlassian should be able to easily cache these types of requests that have no parameters. Let’s hear what the Atlassian staff has to say :slight_smile:

Hey All,

Thanks for this information. I’m going to have a chat with the team to unpack this further. :slight_smile:

2 Likes

Hey @danielwinterw,
is there anything new we can expect?

Hey @FranzBinder,

I’m still discussing this internally. I will let you know if there are any updates :slight_smile:

Hey @danielwinterw,
you all were probably busy with prepaparing the last updates / announcements. :+1:
May be this are still beginners questions … - I’m still curious if you have any news for me!

In the meantime I tried a few things in my Confluence dummy app. This may be also input for you.
I appreciate your adivce. Thanks in advance!

Get the current locale

As @clouless suggested:
Using const response = await api .asUser() .requestJira("/rest/api/3/mypreferences/locale", ... works fine.

My concerns:

  • A Jira call inside a Confluence Forge app requires additional permissions in manifest.yml (manage:jira-configuration) and forge install for Jira as well
  • Nevertheless I was asked for allowing permission during runtime.

Am I doing something wrong? But this doesn’t seem straigthforward for me.

Test with LinguiJS ( https://lingui.js.org/ )
I tried to use this approach due to the small footprint - which should be the same interest for Atlassian.

My first impressions:

  • import { I18nProvider } from "@lingui/react"; let to a forge deploy error: “… react missing in node module @lingui/react/cjs

  • So I installed : npm i --peerdeps react@^15.0.0
    => no more deploy errors.

  • The code

return (
<Fragment>
  <I18nProvider language="en">
    <Text>
      {config.name} is {config.age} years old. Language is {locale}
    </Text>
  </I18nProvider>
</Fragment>

let to runtimee error “Cannot call a class as a function …:open_mouth:
The reason is the new component <I18nProvider>

You cannot use React on the serverside together with Forge UI.
You will need to write your own logic for Forge UI.
I18nNext can only be used with React in Custom UI together with React.

2 Likes