lbrycrd/doc/translation_process.md

110 lines
6.2 KiB
Markdown
Raw Permalink Normal View History

2011-11-08 16:19:52 +01:00
Translations
============
The Bitcoin-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, Bitcoin-Core makes use of the Transifex online translation management tool.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
### Helping to translate (using Transifex)
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.
2011-11-08 16:19:52 +01:00
2016-09-20 04:17:27 +02:00
Multiple language support is critical in assisting Bitcoins global adoption, and growth. One of Bitcoins greatest strengths is cross-border money transfers, any help making that easier is greatly appreciated.
2011-11-08 16:19:52 +01:00
2019-02-14 11:48:53 +01:00
See the [Transifex Bitcoin project](https://www.transifex.com/bitcoin/bitcoin/) to assist in translations. You should also join the translation mailing list for announcements - see details below.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
### Writing code with translations
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:
`bitcoin_xx_YY.ts or bitcoin_xx.ts`
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
`src/qt/locale/bitcoin_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 `bitcoin_en.ts`.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
To automatically regenerate the `bitcoin_en.ts` file, run the following commands:
```sh
cd src/
make translate
2014-09-04 12:45:28 +02:00
```
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
`contrib/bitcoin-qt.pro` takes care of generating `.qm` (binary compiled) files from `.ts` (source files) files. Its mostly automated, and you shouldnt need to worry about it.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
**Example Qt translation**
```cpp
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
```
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
### Creating a pull-request
For general PRs, you shouldnt 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.
2011-11-08 16:19:52 +01:00
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.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
To create the pull-request, use the following commands:
```
git add src/qt/bitcoinstrings.cpp src/qt/locale/bitcoin_en.ts
git commit
```
2014-12-03 02:22:12 +01:00
### Creating a Transifex account
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.
2019-02-14 11:48:53 +01:00
You can find the Bitcoin translation project at [https://www.transifex.com/bitcoin/bitcoin/](https://www.transifex.com/bitcoin/bitcoin/).
2014-12-03 02:22:12 +01:00
### Installing the Transifex client command-line tool
2018-06-01 20:26:48 +02:00
The client is used to fetch updated translations. If you are having problems, or need more details, see [https://docs.transifex.com/client/installing-the-client](https://docs.transifex.com/client/installing-the-client)
2014-12-03 02:22:12 +01:00
`pip install transifex-client`
2018-03-02 22:00:25 +01:00
Setup your Transifex client config as follows. Please *ignore the token field*.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
```ini
nano ~/.transifexrc
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
[https://www.transifex.com]
hostname = https://www.transifex.com
password = PASSWORD
token =
username = USERNAME
```
2011-11-08 16:19:52 +01:00
2018-08-02 20:49:48 +02:00
The Transifex Bitcoin project config file is included as part of the repo. It can be found at `.tx/config`, however you shouldnt need to change anything.
2011-11-08 16:19:52 +01:00
2014-12-03 02:22:12 +01:00
### Synchronising translations
To assist in updating translations, a helper script is available in the [maintainer-tools repo](https://github.com/bitcoin-core/bitcoin-maintainer-tools).
2011-11-08 16:19:52 +01:00
1. `python3 ../bitcoin-maintainer-tools/update-translations.py`
2. `git add` new translations from `src/qt/locale/`
3. Update `src/qt/bitcoin_locale.qrc` manually or via
```bash
git ls-files src/qt/locale/*ts|xargs -n1 basename|sed 's/\(bitcoin_\(.*\)\).ts/ <file alias="\2">locale\/\1.qm<\/file>/'
```
4. Update `src/Makefile.qt_locale.include` manually or via
```bash
git ls-files src/qt/locale/*ts|xargs -n1 basename|sed 's/\(bitcoin_\(.*\)\).ts/ qt\/locale\/\1.ts \\/'
```
2014-12-03 02:22:12 +01:00
**Do not directly download translations** one by one from the Transifex website, as we do a few post-processing steps before committing the translations.
### Handling Plurals (in source files)
When new plurals are added to the source file, it's important to do the following steps:
1. Open `bitcoin_en.ts` in Qt Linguist (included in the Qt SDK)
2. Search for `%n`, which will take you to the parts in the translation that use plurals
3. Look for empty `English Translation (Singular)` and `English Translation (Plural)` fields
4. Add the appropriate strings for the singular and plural form of the base string
5. Mark the item as done (via the green arrow symbol in the toolbar)
6. Repeat from step 2, until all singular and plural forms are in the source file
7. Save the source file
### Translating a new language
2016-09-08 13:58:55 +02:00
To create a new language template, you will need to edit the languages manifest file `src/qt/bitcoin_locale.qrc` and add a new entry. Below is an example of the English language entry.
2014-12-03 02:22:12 +01:00
```xml
<qresource prefix="/translations">
<file alias="en">locale/bitcoin_en.qm</file>
...
</qresource>
```
**Note:** that the language translation file **must end in `.qm`** (the compiled extension), and not `.ts`.
### Questions and general assistance
The Bitcoin-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 #bitcoin-core-dev`.
2014-12-03 02:22:12 +01:00
2015-04-28 16:48:28 +02:00
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.