-
Notifications
You must be signed in to change notification settings - Fork 8
Localizing the Adapt It Mobile User Interface
We currently are using i18next.js, an open source javascript library, to localize the Adapt It Mobile UI. Current localizations include:
- English (en / default)
- French (fr)
- Spanish (es)
- Tok Pisin (tpi / Papua New Guinea)
Localized strings are found in the www/locales folder, under the ISO 639 code for the locale.
-
Open up the www/locales/dev/translation.json file and search for the comment:
// Add new strings BEFORE this line!
-
Add a new line before the comment, and type in the name of the string key and value like this:
"myNewKey": "My cool new localized string value.",
Make sure your key is unique so that it can be found by i18next when it does the lookup.
- Copy this new line to the clipboard.
- Open each of the translation.json files -- there should be one in each locale folder -- and paste the line in just before the comment line. This is probably the most important step, to make sure each locale stays in sync.
tip: to verify
Because we are using Handlebars.js for templated html, there are a couple places where localized strings show up in the code.
To add a localized string to one of the handlebars template files (under www/tpl), add it in the following form:
{{ t 'view.myNewKey'}}
There is a handlebars helper function in router.js called 't' that will do the localization for you as the handlebars file is being "compiled" to html.
There are also some places where localized strings show up in the javascript code. For these, use the i18n.t method:
// assuming a var i18n = require('i18n'); is at the top of the file somewhere...
var localizedString = i18n.t('view.myNewKey');
Home | About | Using Adapt It Mobile | Contributing | Copyright © 2014-2024 Adapt It
- Localizing the Adapt It Mobile User Interface
- Creating Graphics for Adapt It Mobile
- Reporting a problem / bug
- Developing Adapt It Mobile on Linux
- Developing Adapt It Mobile on OS X
- Developing Adapt It Mobile on Windows
- Getting Started with the code
- Compiling locally
- Running in an emulator
- Debugging
- Tips and Tricks
- Development Troubleshooting