Skip to content

Localization

Benjamin Wheeler edited this page Jan 15, 2021 · 6 revisions

Overview

The file msg/messages.js defines all the messages used by scratch-blocks.

The file msg/scratch_msgs.js contains all the translations for scratch-blocks. It is generated from translations in the Scratch translation service Transifex.

The tests ensure that the translations are consistent with the definitions. So adding messages or changing message placeholders require developer access to the Scratch project on Transifex.

If you submit a PR that changes messages.js and you are not a Scratch Team member, the translation tests should fail. Make sure you check the 'Allow edits from maintainers' option on your PR, and then tag a Scratch Team member to push a commit to your branch that includes translations. All the tests other than test:messages should run correctly before you submit the PR.

Updating translations

New and updated translations from the transifex system need to be checked in as a modification to scratch_msgs.js.

  1. Run npm run translate:update*
  2. There should only be changes to scratch_msgs.js, commit the changes and submit as a PR.
  3. Assuming the only changes are translations, you can merge the PR when the tests pass (it does not need a separate review)

*Note: the translation scripts include validation checks for translations. If there are no translation errors then updating translations is only a matter of minutes. If there are translation errors, then they have to be found and fixed in transifex, and that can be more time consuming.

Adding languages

When languages are added in scratch-l10n, the dependency in scratch-blocks needs to be updated, and the new translations downloaded.

  1. Branch scratch-blocks from develop into a feature branch called something like "add-francais"
  2. Edit the package.json to refer to the version of scratch-l10n that includes the new languages
  3. Run npm i scratch-l10n to install the new version
  4. Run npm run translate:sync:translations to download new translations. Make sure there are translations for the new languages.
  5. Push the branch and create a PR (example: https://github.com/LLK/scratch-blocks/pull/2079/files )
  6. Review the PR and merge to develop
Clone this wiki locally