-
Notifications
You must be signed in to change notification settings - Fork 190
Developer Guide
There are two parts to localizing a new repository, extracting the source strings to be translated and syncing them with transifex, and pulling translations from transifex to be incorporated into the component.
Strings in the source are localized by using the FormattedMessage
jsx component or calling formatMessage
, and they can also be defined with defineMessages
.
See Adding a language.
If you are adding a language, do so before updating the translations (below).
Note that these instructions are often followed after following those at https://github.com/LLK/scratch-gui/wiki/Localization .
This can only be run by someone with developer credentials on Transifex.
For the time being, we are not pulling everything that scratch-l10n is configured to request -- we just want the translations for a given Transifex project, like scratch-editor
or scratch-website
.
Sync editor translations:
> npm run pull:editor
or
> npm run pull:www
or
> npm run pull:blocks
etc.
Test that the updated translations have no issues with json formatting by running npm test
.
Use git to commit these changes and push them to your fork on a branch named something like translations-<readable date>
, such as translations-sep-18-2018
.
Then create a pull request and request review. Note that the PR should be set to merge to the master
branch.
When the PR looks good, merge it. Greenkeeper will automatically initiate updates to the packages that depend on scratch-l10n
.
Assuming that source strings have been extracted and sync'd to Transifex, here are the steps to add a new translation 'resource' -- a category of translations for a particular project.
- Add the new resource to
.tx/config
- for example, adding the pen extension strings:
[experimental-scratch.pen]
file_filter = pen/<lang>.json
source_file = pen/en.json
source_lang = en
type = CHROME
- Run
tx pull -a -s
to pull down all translations and the source file. [Note: this will also update other resources that have new translations. If you only want to update the new resource add-r 'experimental-scratch.pen'
(i.e. the resource slug) to the command] - Add the new component to the list of components in
build-data.js
The script assumes that the name of the component is the name of the folder that contains the translations.