-
Notifications
You must be signed in to change notification settings - Fork 8
Localizing the Adapt It Mobile User Interface
We currently have user interface localizations for:
- English (en / default)
- French (fr)
- Spanish (es)
- Tok Pisin (tpi / Papua New Guinea)
If you come across an untranslated or mistranslated string in the user interface, you can use the issue tracker to report the issue to us. Please provide the following information, and we can correct the problem:
- What the UI string currently says
- What it should say
Note: If you are not comfortable making modifications to the code, but would still like to add your language, just let us know. We can perform the following steps for you, and you would only need to provide the localized strings. Thanks!
- Create a new subfolder under www/locales with the ISO 639-1 code for the language (use the ISO 639-3 code if there is no 2-character ISO 639-1 code defined).
- Copy the two files
local.strings
andtranslation.json
from the www/locales/dev directory into the newly-created directory. - Add your language code and name as an option to the file www/tpl/UILanguage.html. This will ensure that users will be able to switch to your language even if their mobile device doesn't directly support it (like Tok Pisin).
- Localize the strings found in the
translation.json
file copy in your new directory.
Localized strings are found in the www/locales folder, under the ISO 639 code for the locale.
-
Open up the www/locales/[your language code]/translation.json file and search for the line:
"_comment" : "Add new strings BEFORE this line!"
-
Add a new line before the line, and type in the name of the string key and value like this (make sure your key is unique so that it can be found by i18next when it does the lookup):
"myNewKey": "My cool new localized string value.",
-
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 the json syntax, do the following:
- Copy the ENTIRE translation.json file text to the clipboard.
- Open up a browser window and navigate to http://jsonlint.com/.
- Paste the translation.json text into the text area.
- Click the Validate button.
We are currently using i18next.js, an open source javascript library, to localize the Adapt It Mobile UI. We also have some helper methods written to integrate the strings with our Handlebars.js templates. 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'}}
For variable replacement, use this form:
{{ tr this key='view.myNewKey' }}
There are a set of helper methods in the file www/js/utils/HandlebarHelpers.js 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...
// simple localized string
var localizedString = i18n.t('view.myNewKey');
// localized string with variable replacement
var localizedString = i18next.t('view.myNewKey', {var: myVariable});
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