Localization notes for coders - cogstat/cogstat GitHub Wiki

Instruction for translators can be found here.

Localization related bugs are here.

Localizable strings

  • If possible, the strings shouldn't include spaces, newlines (issue #144) or other non-printing characters before or after the sentence/expression. These characters are hard to see and handle correctly for the localizers.
  • Unless there's a strong reason not to do so, the to-be-localized string shouldn't include a full stop or colon at the end of the sentence or expression, so that the translated string can be used in other strings too, making the number of to-be-translated strings smaller. For example, use 'Two variables', instead of 'Two variables.' or 'Two variables:'.
  • If a string includes several sentences and/or expressions that can be found in other locations of the code too, then localize these components separately and concatenate them. For example, instead of saying 'Interval variables. Two variables.', use 'Interval variables' and 'Two variables' separately, then concatenate them. This method needs less text to localize.
  • For a similar message use the same string, and do not use some synonyms, so that the single string should be translated only once, instead of translating multiple string versions with the same meaning.
  • Send comments to the localizers: if needed, add a comment starting with translators: in a separate line before the string. See also the possible limitation of POEditor below.
  • TBD Which string formatting method to use? It should be easily understood by the localizers.
    • TBD Concatenate strings with + (which is easier to read) or with join() (which is faster)? Or use f-string (which does not work with xgettext)?

Adding a new language to CogStat

  • POEditor
    • Add the language to POEditor
    • After the .po and .mo files are in the code (see below), connect the POEditor and the GitHub files (master branch)
  • In the code
    • Create the new language code directory in locale directory, add the .po and .mo files from poeditor export
    • Extend the language list for Preferences dialog in cogstat_dialogs.py
    • Extend the changelog with the language and the translator
  • Other places

Updating the localizations

  • Updating the pot for the translators
    • Run generate_pot in the locale directory which refreshes the cogstat.pot file
    • In POEditor: Project page, Import, choose the pot file, click Import file
      • If some strings are not used anymore, they can be selected to be removed (the ones that have changed only slightly could stay until the next release to help the translators to see the previous translations)
  • Sync translations from POEditor to GitHub
    • Project Settings > GitHub, choose the languages to export, Export to GitHub (check which branch this goes; currently to master)

Note for POEditor administrators

POEditor limitations

  • POEditor can import comments for the string from pot file, only if the string is new.
  • After importing terms from a .pot file linked from the GitHub page, POEditor will not delete unused terms. Still, this can be done
    • with Webhooks (GitHub integration page > Generate Webhook > Operation: Synv terms and translations > access the link)
    • or with manual import terms (after the import obsolete terms can be selected and deleted).

Note for transifex administrator

Problem. When uploading already translated .po files, transifex checks if %something is the same both in the source and target languages. However, this is unnecessary, e.g., in '95% confidence interval'. '95%%' would print 95%%, so using it is not a solution.

Solution. To overcome the problem,

  1. disable the translation check as described here,

  2. and remove the "#, python-format" lines (automatically generated by xgettext) from the appropriate strings in the .po files.