How to add a language


For now, only English and French are available but in the future we hope to cover more languages.

Update the phone app

Adding a language

For now, each language is declare staticly in www/js/app.js.

$translateProvider
.fallbackLanguage('en')
.registerAvailableLanguageKeys(['en', 'fr'], {
    'en_*': 'en',
    'fr_*': 'fr',
    '*': 'en'
})
.determinePreferredLanguage()
.useStaticFilesLoader({
    prefix: 'i18n/',
    suffix: '.json'
});

To add a language to the app, we have to register a new language key. If I want to add deutsch, I will modify the file like below:

$translateProvider
.fallbackLanguage('en')
.registerAvailableLanguageKeys(['en', 'fr','de'], {
    'en_*': 'en',
    'fr_*': 'fr',
    'de_*': 'de',
    '*': 'en'
})
.determinePreferredLanguage()
.useStaticFilesLoader({
    prefix: 'i18n/',
    suffix: '.json'
});

Changing the fallback language

By default, the fallback language is english but it can easily be modified by just changing en in the line below by the key of your language in www/js/app.js.

.fallbackLanguage('en')

You can find more information about the fallback language in the documentation.

Adding custom translations

If you do not want to use the translation provided by e-mission-translate you can either fork the repo or just delete the line below from the config.xml to stop using the hook which is pulling the translation from the git repo.

<hook src="hooks/before_prepare/download_translation.js" type="before_prepare" />

If you chose to fork the repo, do not forget to add bin/conf/translate_config.json and add the link of the forked repo as below.

{
    "url": "https://github.com/e-mission/e-mission-translate"
}