Skip to content
Valentin Mourot edited this page May 3, 2019 · 1 revision

Internationalization

Mobile Framework provides an I18n wrapper to help you translate you application modules and Timeline modules.

The i18n module located at /app/infra/i18n.ts loads the locales and all the i18n keys defined in /assets/i18n, and set the application language based on the device settings.

When you have to translate a string in your module, don't use the i18n npm package. Use this wrapper instead by using import { I18n } from "../infra/i18n";

When you want to display or manage dates and times, don't use the moment npm package. Use this wrapper instead by using import { moment, IMoment } from "../infra/i18n".

This wrapper ensures you that all translated modules will be configured in the same locale.

Add translation keys

I18n keys are not externalized in their own application module or Timeline module yet.

To add a translation key, open in /assets/i18n every language file, and create the key you want. Try to keep all languages files synchronized : one line number key key across the languages, keys ordered lexically.

Add a language

Create the appropriate language file in the /assets/i18n folder, and make these alterations in app/infra/i18n.ts :

  1. Line ~14: import the corresponding moment.js locale
  2. Line ~24: require the language file you just created

Clone this wiki locally