| 1 | Monero daemon internationalization |
| 2 | ================================== |
| 3 | |
| 4 | The Monero command line tools can be translated in various languages. If you wish to contribute and need help/support, contact the [Monero Localization Workgroup on Taiga](https://taiga.getmonero.org/project/erciccione-monero-localization/) or come chat on `#monero-translations` (Libera/IRC, riot/matrix, MatterMost) |
| 5 | |
| 6 | In order to use the same translation workflow as the [Monero Core GUI](https://github.com/monero-project/monero-gui), they use Qt Linguist translation files. However, to avoid the dependencies on Qt this normally implies, they use a custom loader to read those files at runtime. |
| 7 | |
| 8 | ### Tools for translators |
| 9 | |
| 10 | In order to create, update or build translations files, you need to have Qt tools installed. For translating, you need either the **Qt Linguist GUI** ([part of Qt Creator](https://www.qt.io/download) or a [3rd-party standalone version](https://github.com/lelegard/qtlinguist-installers/releases)), or another tool that supports Qt ts files, such as Transifex. The files are XML, so they can be edited in any plain text editor if needed. |
| 11 | |
| 12 | ### Creating / modifying translations |
| 13 | |
| 14 | You do not need anything from Qt in order to use the final translations. |
| 15 | |
| 16 | To update ts files after changing source code: |
| 17 | |
| 18 | ```bash |
| 19 | ./utils/translations/update-translations.sh |
| 20 | ``` |
| 21 | |
| 22 | To add a new language, eg Spanish (ISO code es): |
| 23 | |
| 24 | ```bash |
| 25 | cp translations/monero.ts translations/monero_es.ts |
| 26 | ``` |
| 27 | |
| 28 | To edit translations for Spanish: |
| 29 | |
| 30 | ```bash |
| 31 | linguist translations/monero_es.ts |
| 32 | ``` |
| 33 | |
| 34 | To build translations after modifying them: |
| 35 | |
| 36 | ```bash |
| 37 | ./utils/translations/build-translations.sh |
| 38 | ``` |
| 39 | |
| 40 | To test a translation: |
| 41 | |
| 42 | ```bash |
| 43 | LANG=es ./build/release/bin/monero-wallet-cli |
| 44 | ``` |
| 45 | |
| 46 | To add new translatable strings in the source code: |
| 47 | |
| 48 | Use the `tr(string)` function if possible. If the code is in a class, and this class doesn't already have a `tr()` static function, add one, which uses a context named after what `lupdate` uses for the context, usually the fully qualified class name (eg, `cryptonote::simple_wallet`). If you need to use `tr()` in code that's not in a class, you can use the fully qualified version (eg, `simple_wallet::tr`) of the one matching the context you want. Use `QT_TRANSLATE_NOOP(string)` if you want to specify a context manually. |
| 49 | |
| 50 | If you're getting messages of the form: |
| 51 | |
| 52 | ``` |
| 53 | Class 'cryptonote::simple_wallet' lacks Q_OBJECT macro |
| 54 | ``` |
| 55 | |
| 56 | all is fine, we don't actually need that here. |