| 1 |
Translations |
| 2 |
============ |
| 3 |
|
| 4 |
Translations can be done either via |
| 5 |
`Weblate <https://hosted.weblate.org/projects/copyq/>`__ (preferred) or |
| 6 |
by using Qt utilities. |
| 7 |
|
| 8 |
For explanation for some frequent words see :ref:`glossary`. |
| 9 |
|
| 10 |
Translating Keyboard Accelerators |
| 11 |
--------------------------------- |
| 12 |
|
| 13 |
Some texts contain single ``&`` character that is not visible in UI and is used |
| 14 |
to mark the following character as keyboard accelerator (the character is |
| 15 |
usually underlined in UI). This is used to quickly access labels, menu items |
| 16 |
etc. with keyboard shortcut. |
| 17 |
|
| 18 |
E.g. ``&File`` menu item can be accesses with ``Alt+F`` shortcut on most |
| 19 |
systems. |
| 20 |
|
| 21 |
If multiple UI elements have the same keyboard accelerator, associated shortcut |
| 22 |
cycles through them (if pressed multiple times). It's better to avoid this by |
| 23 |
defining **unique accelerator**, but that's not always easy. |
| 24 |
|
| 25 |
If unsure, use the original one enclosed in parentheses, e.g. label |
| 26 |
``For&mat:`` can be translated to simplified Chinese as ``格式(&M):``. |
| 27 |
|
| 28 |
Writing Translatable Code |
| 29 |
------------------------- |
| 30 |
|
| 31 |
All GUI strings should be translatable. This is indicated in code with |
| 32 |
``tr("Some GUI text", "Hints for translators")``. |
| 33 |
|
| 34 |
Adding New Language |
| 35 |
------------------- |
| 36 |
|
| 37 |
To add new language for the application follow these steps. |
| 38 |
|
| 39 |
1. Create new translation file with |
| 40 |
``utils/lupdate.sh translations/copyq_<LANGUAGE>.ts``. |
| 41 |
2. Add new language file to Git repository. |
| 42 |
3. Translate with Weblate service or locally with |
| 43 |
``linguist translations/copyq_<LANGUAGE>.ts``. |
| 44 |
|
| 45 |
Updating Translations |
| 46 |
--------------------- |
| 47 |
|
| 48 |
To push and pull changes from Weblate safely, `avoiding merge conflicts |
| 49 |
<https://docs.weblate.org/en/latest/admin/continuous.html#avoiding-merge-conflicts>`_, |
| 50 |
you can use `Weblate Client <https://docs.weblate.org/en/latest/wlc.html>`_. |
| 51 |
|
| 52 |
Install Weblate Client: |
| 53 |
|
| 54 |
.. code-block:: bash |
| 55 |
|
| 56 |
pip3 install -U --user wlc |
| 57 |
|
| 58 |
Lock and push changes from Weblate (remember to unlock later): |
| 59 |
|
| 60 |
.. code-block:: bash |
| 61 |
|
| 62 |
wlc lock |
| 63 |
wlc push |
| 64 |
git pull |
| 65 |
|
| 66 |
Update and push new translations to repository: |
| 67 |
|
| 68 |
.. code-block:: bash |
| 69 |
|
| 70 |
utils/lupdate.sh |
| 71 |
git add translations/ |
| 72 |
git commit -m "Update translations" |
| 73 |
git push |
| 74 |
|
| 75 |
Pull changes to Weblate and unlock: |
| 76 |
|
| 77 |
.. code-block:: bash |
| 78 |
|
| 79 |
wlc pull |
| 80 |
wlc unlock |