Skip to content

Developer Guide

chrisgarrity edited this page Jul 30, 2019 · 3 revisions

Localizing Scratch

Setting up a new repository

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.

Extracting source strings in React source files

Strings in the source are localized by using the FormattedMessage jsx component or calling formatMessage, and they can also be defined with defineMessages.

Adding new languages

See Adding a language.

If you are adding a language, do so before updating the translations (below).

Updating the current translations

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.

Pull translations from 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 translations

Test that the updated translations have no issues with json formatting by running npm test.

Create a pull request

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.

Adding a new translation resource to the l10n repo

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.

  1. 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
  1. 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]
  2. 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.