Quentin Harnay
Quentin Harnay

Reputation: 120

No way to handle internationalization (i18n)?

I'm wondering if there is any way to handle i18n while building HTML/Js apps using trigger.io (forge).

By the way, there is also no way to detect user's locale on devices, workarounding by inspecting User Agent ( or in my case - a FB connect app - asking FB to get the user's locale)

Internationalization is a must have for any serious app ... I'm currently "hacking" this by creating several JSON files (one per locale), holding same keys in the appropriate language.

1: Is there any plan of detecting/getting user's locale with forge Js API ? 2: Is there any plan to handle automated i18n while building apps ?

Tks.

Upvotes: 1

Views: 286

Answers (2)

sandstrom
sandstrom

Reputation: 15092

There are two things to translate: your JS/HTML app and the native elements.

JS/HTML

Use window.navigator.language to get the locale. Use some library, e.g. https://github.com/wikimedia/jquery.i18n

Native

The native elements aren't shown that often, but do contain some crucial things, such as permissions dialogs ('The app wants access to your photos').

There is currently no support in trigger.io for translating this section that I know of, i.e. they will all be in english.

But as I understand it trigger.io could add support for this fairly easily, by just making it possible to 'switch' on more languages in config.json, since there are already translations for these dialogs built into iOS, just a matter of 'flagging' an app as having support for the language.

Again, I'm not 100% sure on the native part, but this is how I think it works.

Upvotes: 0

Patrick Rudolph
Patrick Rudolph

Reputation: 2241

You could easily write a Trigger.io plugin to detect the device language for you. Here are some resources on how to do this:

As soon as you have the language string you could then use one of many js plugins that handle localization for you OR do it on your own. Having multiple json files with the localized strings and loading one of them on demand doesn't sound too hacky to me.

PS: Of course, if you plan to have a mobile browser version of your app you cannot rely on native plugins. In this case you'd have to use a different solution. Take a look at JavaScript for detecting browser language preference.

Upvotes: 1

Related Questions