-
Notifications
You must be signed in to change notification settings - Fork 19
Description
This isn't a bug report or a feature request. More of a general inquiry or an RFC (in fact, I'd love to debate some implementation details).
I was wondering what your stance on i18n (internationalization. In this instance, a focus on localization specifically) was.
Is this something you'd like to see supported in the foreseeable future?
I currently work on a set of simple i18n libraries for both Go and TypeScript (aptly dubbed Rosetta-Go and Rosetta-TS, respectively).
Both libraries follow the Chrome i18n API (just the basics, so far. No placeholder support, yet).
In its most basic incarnation there's a locales directory. Inside that locales directory are folders named for language shortcodes (en, fr, de, etc. So far, no support for country-specific shortcodes). Inside each of these folders is a messages.json file that adheres to the following basic pattern (where "new_map_title" and "new_map_text" are unique keys, and the contents of the "message" fields the language-specific display text):
{
"new_map_title": {
"message": "New map"
},
"new_map_text": {
"message": "This will erase all editor contents. Proceed?"
}
}To quickly switch between languages in the browser, the user may provide a lang argument (i. e. www.trizbort.io/app/index.html?lang=fr — or www.trizbort.io/app/index.html?map=hobbit&lang=fr, to load a new map while also switching the language to French).
If a language code is not recognized, the application will launch with the default fallback language (English, for Trizbort) instead. Although here one may also consider checking the browser language (window.navigator.language) against the array of supported languages.
Both i18n libraries will provide a GetMessage(key: string) method to place a translation.
The translation specific code for the screenshots below looks as follows:
actionNewMap() {
new Window(i18n.getMessage("new_map_title"), i18n.getMessage("new_map_text"), () => {
// OK
App.map = new Map();
Dispatcher.notify(AppEvent.Load, null);
}, () => {
// Cancel
});
}The beauty of utilizing Chrome i18n lies in its simplicity, as well as the compatibility with most online translation providers like Transifex or Crowdin.
Screenshots: A first WIP implementation running in my fork.

