To add a new language, follow these four steps:
1. Register the locale
Edit src/js/stores/LocaleStore.js. Add your language code to langLocaleMap. Optionally, add mappings to headerLocaleMap to support browser Accept-Language headers.
// In langLocaleMap:
xx: 'xx_XX',
// In headerLocaleMap (optional):
'xx-XX': 'xx_XX',
'xx': 'xx_XX',
2. Add the UI button
Edit src/js/react_views/IntlHelperBarView.jsx and add a new object to the getItems() array to allow users to select the language via the UI.
}, {
text: 'Your Language Name',
testID: 'yourlanguage',
onClick: function() {
this.fireCommand('locale xx_XX; levels');
}.bind(this)
}, {
3. Translate UI strings
Edit src/js/intl/strings.js. For every existing key, add your new locale key and the translated string.
"finish-dialog-finished": {
"en_US": "Wow! You finished the last level, great!",
"xx_XX": "Your translation here"
},
4. Translate level content
In every file within src/levels/, add your locale to the name, hint, and startDialog fields.
"name": {
"en_US": "Introduction to Git Commits",
"xx_XX": "Your translated level name"
},
"hint": {
"en_US": "Try using git commit",
"xx_XX": "Your translated hint"
},
"startDialog": {
"en_US": { "childViews": [...] },
"xx_XX": {
"childViews": [
{
"type": "ModalAlert",
"options": {
"markdowns": [
"## Your Translated Title",
"Your translated paragraph text."
]
}
}
]
}
}