Working on translations

Overview

NOTE: Steps 3 and 4 aren’t sequential; they’re different translation processes

Step 1: What is the ll_CC locale name for my language?

Screenshot of localization files in PsychoPy®

Image of where the localisation files reside in the PsychoPy repository

1a: Examples of East Asian locale names

ll_ (language), followed by _CC (country), for example:

1b: Examples of Central/Western Asian/European locale names

* This is the official locale for MSA. Let’s just hope the _001 code works in PsychoPy®. If not, we can switch to country codes (e.g., ar_EG for Arabic in Egypt)

1c: Some other Indo-European languages

1d: What if our language needs more than one language variety?

1e: Example using Spanish

  • fully translate for Iberian Spanish (es_ES)
  • copy the entire es_ES folder
  • rename it to es_CL (Spanish in Chile)
  • add Chilean Spanish to the mappings.txt file
  • make adjustments to the new messages.po file to account for Chilean variations on the language

1f: ll_CC folder/file structure

psychopy/psychopy/app/locale/...

folder structure for locations of dot po and dot mo files (this one being fa_IR, which is Farsi as spoken in Iran)

NOTE: Ignore the intermediate LC_MESSAGE level, as well as the messages.mo file underneath

1g: Is your locale listed?

1h: How to add a locale

Step 2: Update mappings.txt

2a: Open a text editor

2b: Insert the appropriate ll_CC code

/psychopy/psychopy/app/localization/mappings.txt

2c: Add the Microsoft language code

NOTE: If you can’t find your language for some reason, just add a random three-letter sequence that isn’t already in use and probably doesn’t refer to a language (e.g., JJY). That should work.

2d: Add an informative language label

2e: Make a pull request for mappings.txt

2e1: Stage changes

2e2: Commit staged changes

2e3: Push to origin

  • click the Push origin tab

2e4: Pull request from origin to upstream

FINISHED!! (with mappings.txt)

Step 3: Translating strings in Poedit

3a: Sync all your repositories

Again??!!

3b: Download and install Poedit

Poedit download page

3c: Check General settings

3c1: General tab (Name and email)

3c2: Leave name and email blank

3c3: check the Advanced settings

3d: Settings specific to a .po file

First, open the .po file

3d1: language team

3d2: language

3d3: Paths (1)

..THE/PATH/ON/YOUR/COMPUTER/TO/psychopy/psychopy

NOTE: This setting does not make its way into the .po file. Rather, it’s just part of Poedit.

3d4: Paths (2)

3d5: keywords

_translate

3e1: Generate current list of translatable strings

3e2: Generate the list

NOTE: If Update from Source Code is greyed out, there are probably no new strings to update

3g: Group strategy: Sort and show string ID

3h: Translate the strings

3i: Make a pull request for messages.po

3i1: Stage changes

3i2: Commit staged changes

3i3: Push changes to origin

3i4: pull request to upstream

Note A: Leave certain technical terms alone

Note B: Formatting arguments

If there are formatting arguments in the original string (%s, %(first)i)

* Word order changes across languages, of course. So the placement of these formatting arguments within the translated string may differ from the US-English string.

Note C1: Using the Japanese .po file for guidance

/psychopy/app/locale/ja_JP/LC_MESSAGES/messages.po

Note C2: When you are unsure how to translate

If you think your translation might have room for improvement

Note C2a: Simple strategy to resolve uncertainty: Ask the experts

Note C2b: Advanced strategy to resolve uncertainty: Determine it yourself

NOTE: You need to understand Python quite well to take the following approach

Note C2b (cont’d)

Note C2c: Last resort: Do nothing

If still in doubt

Step 4: Translating the Start-up Tips

4a: Copy tips.txt to a new file

4b: translate

WARNING: Do not delete any English entry in the new .txt file before you have completely translated it. Instead, insert the relevant translation below the English entry. Then (and only then) delete the English entry. Save your work, of course.

4c: treat the .txt files as strings in Poedit

The case of Japanese
Source text - English Translation - Japanese
tips.txt tips_ja_JP.txt

4d: Make a pull request for .po and .txt files

There are two files this time

4d1: Stage changes

IMPORTANT: Again, be sure to UN-check the .mo file if it is checked.

4d2: Commit changes

4d3: Push changes to origin

4d4: pull request to upstream

Note on humor in Start-up tips

Done with translating

More details on More information on Git workflow