| 1 |
Translations |
| 2 |
============ |
| 3 |
|
| 4 |
Bonsai supports translations to all languages that Blender supports. We'll |
| 5 |
describe how you can help translate the add-on as a translator, or how you can |
| 6 |
ensure your strings are translatable as a developer. Translations are managed |
| 7 |
using a separate add-on built for this purpose. |
| 8 |
|
| 9 |
1. Clone the `bonsai-translations |
| 10 |
<https://github.com/IfcOpenShell/bonsai-translations>`_ repository. This |
| 11 |
repository holds all the core translation strings in ``.po`` format. |
| 12 |
2. Download the `bonsai-translations add-on |
| 13 |
<https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/bonsai/scripts/bbim_translations.py>`_ |
| 14 |
and install it as a Blender add-on. This add-on lets you convert translation |
| 15 |
data to and from the ``.po`` files for Bonsai. |
| 16 |
3. In the **Render Properties** tab, find the **Bonsai Translations** |
| 17 |
panel, and browse to where you have closed the ``bonsai-translations`` |
| 18 |
repository, and click on **Setup Translation UI**. |
| 19 |
|
| 20 |
You should now see a new interface with two buttons. |
| 21 |
|
| 22 |
.. image:: images/translation-panel.png |
| 23 |
|
| 24 |
How to translate the add-on |
| 25 |
--------------------------- |
| 26 |
|
| 27 |
Before beginning, look inside the ``bonsai-translations`` repository for a |
| 28 |
``.po`` file for the language you want to translate to (e.g. ``de_DE.po`` for |
| 29 |
German). If this file does not yet exist, congratulations! You are the first |
| 30 |
person to translate to this language! Create a folder in |
| 31 |
``bonsai-translations`` with your language code and copy the |
| 32 |
``bonsai.pot`` language template file to that folder and rename it |
| 33 |
according to your language (e.g. for German you would copy ``bonsai.pot`` to |
| 34 |
``de_DE/de_DE.po``). |
| 35 |
|
| 36 |
Supported language codes are: |
| 37 |
|
| 38 |
.. code-block:: |
| 39 |
|
| 40 |
'ca_AD', 'en_US', 'es', 'fr_FR', 'ja_JP', 'sk_SK', 'cs_CZ', 'de_DE', |
| 41 |
'it_IT', 'ka', 'ko_KR', 'pt_BR', 'pt_PT', 'ru_RU', 'uk_UA', 'vi_VN', |
| 42 |
'zh_HANS', 'zh_HANT', 'ab', 'ar_EG', 'bg_BG', 'el_GR', 'eo', 'eu_EU', |
| 43 |
'fa_IR', 'fi_FI', 'ha', 'he_IL', 'hi_IN', 'hr_HR', 'hu_HU', 'id_ID', |
| 44 |
'ky_KG', 'ne_NP', 'nl_NL', 'pl_PL', 'sr_RS', 'sr_RS@latin', 'sv_SE', 'sw', |
| 45 |
'ta', 'th_TH', 'tr_TR'. |
| 46 |
|
| 47 |
As a translator, it is recommended to translate text in bulk by modifying the |
| 48 |
``.po`` files directly. We recommend installing software such as `Poedit |
| 49 |
<https://poedit.net/>`_. These translation software offer features such as auto |
| 50 |
translation, suggestions, and tracking. Alternatively, you may edit the ``.po`` |
| 51 |
file as a text file. |
| 52 |
|
| 53 |
Once you have edited the relevant language's ``.po`` file, click on the |
| 54 |
**Update Translations From .po** button in the **Bonsai Translations** |
| 55 |
panel. |
| 56 |
|
| 57 |
How to add new translation strings |
| 58 |
---------------------------------- |
| 59 |
|
| 60 |
When you have new strings to translate, press the **Parse Bonsai strings to |
| 61 |
.pot** button. This detects strings in the source code using regex patterns and |
| 62 |
writes out to the ``bonsai.pot`` language template file. You may then diff |
| 63 |
this file and propagate changes manually to all translated ``.po`` files. |
| 64 |
|
| 65 |
The ``.pot`` file is only used as a blank template for users to create or |
| 66 |
compare ``.po`` files. The ``.po`` files are the source of truth for |
| 67 |
translation strings. Blender does not read from the ``.pot`` or ``.po`` files. |
| 68 |
Instead, Blender reads from ``bonsai/translations.py`` which contains a |
| 69 |
dictionary of strings formatted specifically for Blender. The |
| 70 |
``translations.py`` file is generated from the ``.po`` files. This is generated |
| 71 |
when we distribute installable packages, or when translators manually press the |
| 72 |
**Update Translations From .po** button. |
| 73 |
|
| 74 |
.. warning:: |
| 75 |
|
| 76 |
Do not commit the ``translations.py`` file as it is auto-generated. |