You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

translation_process.md 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Translations
  2. ============
  3. The Starwels-Core project has been designed to support multiple localisations. This makes adding new phrases, and completely new languages easily achievable. For managing all application translations, Starwels-Core makes use of the Transifex online translation management tool.
  4. ### Helping to translate (using Transifex)
  5. Transifex is setup to monitor the GitHub repo for updates, and when code containing new translations is found, Transifex will process any changes. It may take several hours after a pull-request has been merged, to appear in the Transifex web interface.
  6. Multiple language support is critical in assisting Starwels’s global adoption, and growth. One of Starwels’s greatest strengths is cross-border money transfers, any help making that easier is greatly appreciated.
  7. See the [Transifex Bitcoin project](https://www.transifex.com/projects/p/bitcoin/) to assist in translations. You should also join the translation mailing list for announcements - see details below.
  8. ### Writing code with translations
  9. We use automated scripts to help extract translations in both Qt, and non-Qt source files. It is rarely necessary to manually edit the files in `src/qt/locale/`. The translation source files must adhere to the following format:
  10. `starwels_xx_YY.ts or starwels_xx.ts`
  11. `src/qt/locale/starwels_en.ts` is treated in a special way. It is used as the source for all other translations. Whenever a string in the source code is changed, this file must be updated to reflect those changes. A custom script is used to extract strings from the non-Qt parts. This script makes use of `gettext`, so make sure that utility is installed (ie, `apt-get install gettext` on Ubuntu/Debian). Once this has been updated, `lupdate` (included in the Qt SDK) is used to update `starwels_en.ts`.
  12. To automatically regenerate the `starwels_en.ts` file, run the following commands:
  13. ```sh
  14. cd src/
  15. make translate
  16. ```
  17. `contrib/starwels-qt.pro` takes care of generating `.qm` (binary compiled) files from `.ts` (source files) files. It’s mostly automated, and you shouldn’t need to worry about it.
  18. **Example Qt translation**
  19. ```cpp
  20. QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
  21. ```
  22. ### Creating a pull-request
  23. For general PRs, you shouldn’t include any updates to the translation source files. They will be updated periodically, primarily around pre-releases, allowing time for any new phrases to be translated before public releases. This is also important in avoiding translation related merge conflicts.
  24. When an updated source file is merged into the GitHub repo, Transifex will automatically detect it (although it can take several hours). Once processed, the new strings will show up as "Remaining" in the Transifex web interface and are ready for translators.
  25. To create the pull-request, use the following commands:
  26. ```
  27. git add src/qt/starwelsstrings.cpp src/qt/locale/starwels_en.ts
  28. git commit
  29. ```
  30. ### Creating a Transifex account
  31. Visit the [Transifex Signup](https://www.transifex.com/signup/) page to create an account. Take note of your username and password, as they will be required to configure the command-line tool.
  32. You can find the Starwels translation project at [https://www.transifex.com/projects/p/bitcoin/](https://www.transifex.com/projects/p/bitcoin/).
  33. ### Installing the Transifex client command-line tool
  34. The client it used to fetch updated translations. If you are having problems, or need more details, see [http://docs.transifex.com/developer/client/setup](http://docs.transifex.com/developer/client/setup)
  35. **For Linux and Mac**
  36. `pip install transifex-client`
  37. Setup your transifex client config as follows. Please *ignore the token field*.
  38. ```ini
  39. nano ~/.transifexrc
  40. [https://www.transifex.com]
  41. hostname = https://www.transifex.com
  42. password = PASSWORD
  43. token =
  44. username = USERNAME
  45. ```
  46. **For Windows**
  47. Please see [http://docs.transifex.com/developer/client/setup#windows](http://docs.transifex.com/developer/client/setup#windows) for details on installation.
  48. The Transifex Bitcoin project config file is included as part of the repo. It can be found at `.tx/config`, however you shouldn’t need change anything.
  49. ### Synchronising translations
  50. To assist in updating translations, we have created a script to help.
  51. 1. `python contrib/devtools/update-translations.py`
  52. 2. Update `src/qt/starwels_locale.qrc` manually or via
  53. `ls src/qt/locale/*ts|xargs -n1 basename|sed 's/\(starwels_\(.*\)\).ts/<file alias="\2">locale\/\1.qm<\/file>/'`
  54. 3. Update `src/Makefile.qt.include` manually or via
  55. `ls src/qt/locale/*ts|xargs -n1 basename|sed 's/\(starwels_\(.*\)\).ts/ qt\/locale\/\1.ts \\/'`
  56. 4. `git add` new translations from `src/qt/locale/`
  57. **Do not directly download translations** one by one from the Transifex website, as we do a few post-processing steps before committing the translations.
  58. ### Handling Plurals (in source files)
  59. When new plurals are added to the source file, it's important to do the following steps:
  60. 1. Open `starwels_en.ts` in Qt Linguist (included in the Qt SDK)
  61. 2. Search for `%n`, which will take you to the parts in the translation that use plurals
  62. 3. Look for empty `English Translation (Singular)` and `English Translation (Plural)` fields
  63. 4. Add the appropriate strings for the singular and plural form of the base string
  64. 5. Mark the item as done (via the green arrow symbol in the toolbar)
  65. 6. Repeat from step 2, until all singular and plural forms are in the source file
  66. 7. Save the source file
  67. ### Translating a new language
  68. To create a new language template, you will need to edit the languages manifest file `src/qt/starwels_locale.qrc` and add a new entry. Below is an example of the English language entry.
  69. ```xml
  70. <qresource prefix="/translations">
  71. <file alias="en">locale/starwels_en.qm</file>
  72. ...
  73. </qresource>
  74. ```
  75. **Note:** that the language translation file **must end in `.qm`** (the compiled extension), and not `.ts`.
  76. ### Questions and general assistance
  77. The Starwels-Core translation maintainers include *tcatm, seone, Diapolo, wumpus and luke-jr*. You can find them, and others, in the Freenode IRC chatroom - `irc.freenode.net #starwels-dev`.
  78. If you are a translator, you should also subscribe to the mailing list, https://groups.google.com/forum/#!forum/bitcoin-translators. Announcements will be posted during application pre-releases to notify translators to check for updates.