Phonegap Boilerplate Documentation

Internationalization

Description

Phonegap Boilerplate can display text based on the device preferred locale.

Usage

To use i18n in your, simply require the __ module where you need to display text and use the __.t('translation-key') function to get a translation.

Then, you can extract all the needed translation with :

make i18n-extract : Extract all the strings in www/locales/default/translation.json

make i18n-extract-locale l=<locale> : Extract all the strings in www/locales/<locale>/translation.json

Context

Sometimes, a word translation changes according to the context. To give context to a word, use : __.t('Context::translation-key')

Convert i18next files to po/mo

You can use i18next-conv to convert i18next's json to po/mo and vice versa.

Installation

npm install -g i18next-conv

json to po/mo:

i18next-conv -l <language> -s /path/to/source.json -t /path/to/destination.(mo|po)

po/mo to json:

i18next-conv -l <language> -s /path/to/source.(mo|po) -t /path/to/destination.json

Current language

To get the current app language, you can use window.i18n.lng().

Based on