gui icon indicating copy to clipboard operation
gui copied to clipboard

Translation using XLIFF file

Open hebasto opened this issue 4 years ago • 1 comments

TL;DR

  1. Use Qt Translator Comments to annotate tr() calls
  2. Do not use disambiguation strings in tr() calls, except in item 3
  3. If two or more identical strings have different meanings and could be translated in different ways, use disambiguation strings

Since https://github.com/bitcoin/bitcoin/pull/21694 is merged there is an opportunity for developers to provide an exhaustive context for translatable strings to translators who are working via the Transifex.

Strings in Qt code

Using a Qt TS translation file (pre-21694), v0.21.x and earlier: DeepinScreenshot_select-area_20210421165407

Using a XLIFF translation file (post-21694), v22.x: DeepinScreenshot_select-area_20210421165641

The added "DEVELOPER NOTES" are the main means to provide context to translators in the Transifex editor. See:

  • https://docs.transifex.com/getting-started-as-a-localization-manager/4-provide-context#developer-notes-&-instructions
  • https://docs.transifex.com/translation/tools-in-the-editor#string-instruction-and-developer-notes

To provide such notes in C++ code developers must use Qt Translator Comments that annotate tr() calls: https://github.com/bitcoin-core/gui/blob/e16f8720dca2de1040478968c9f3ca07644a04b7/src/qt/addressbookpage.cpp#L298-L299

Please note, that despite documented support for <context-group> and <context> XML elements of XLIFF file by Transifex, disambiguation strings, i.e., the second argument of tr() call, are not rendered in Transifex editor. Therefore, they add no value to translation process.

Another change is "Context" in the "More Info" tab: a class name (the default context for tr() calls) is replaced with a source file name. Therefore, if knowing a class name is valuable to translators, developers must provide it in translator comments.

Strings in non-Qt code

The only change is "Context" in the "More Info" tab: instead of "bitcoin-core" the bitcoinstrings.cpp file is mentioned.

Handling plural forms

Seems everything works fine. Details:

  • https://docs.transifex.com/localization-tips-workflows/plurals-and-genders#how-pluralized-strings-are-handled-by-transifex
  • https://docs.transifex.com/formats/xliff#plural-support

hebasto avatar Apr 21 '21 19:04 hebasto

Concept ACK, thanks for working on this!

laanwj avatar Apr 21 '21 19:04 laanwj