bitcoin-core / gui

Bitcoin Core GUI staging repository
https://github.com/bitcoin/bitcoin
MIT License
589 stars 259 forks source link

Translation using XLIFF file #287

Open hebasto opened 3 years ago

hebasto commented 3 years ago

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:

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:

laanwj commented 3 years ago

Concept ACK, thanks for working on this!