Skip to content

Commit d5aff85

Browse files
committed
Fix #889. Write docs for how to do translations.
1 parent 708c61e commit d5aff85

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ src/ifcopenshell-python/test/build
7676
# blenderbim libs
7777
src/blenderbim/blenderbim/libs
7878

79+
# blenderbim i18n
80+
src/blenderbim/blenderbim/translations.py
81+
7982
# blenderbim test temp files
8083
src/blenderbim/test/files/temp
8184
src/blenderbim/drawings
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file will be autogenerated and rewritten when packaged.
2+
3+
translations_dict = {}
18 KB
Loading
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Translations
2+
============
3+
4+
The BlenderBIM Add-on supports translations to all languages that Blender
5+
supports. We'll describe how you can help translate the add-on as a translator,
6+
or how you can ensure your strings are translatable as a developer.
7+
Translations are managed using a separate add-on built for this purpose.
8+
9+
1. Clone the `blenderbim-translations
10+
<https://github.com/IfcOpenShell/blenderbim-translations>`_ repository. This
11+
repository holds all the core translation strings in ``.po`` format.
12+
2. Download the `blenderbim-translations add-on
13+
<https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/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 to the BlenderBIM Add-on.
16+
3. In the **Render Properties** tab, find the **BlenderBIM Translations**
17+
panel, and browse to where you have closed the ``blenderbim-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 ``blenderbim-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+
``blenderbim-translations`` with your language code and copy the
32+
``blenderbim.pot`` language template file to that folder and rename it
33+
according to your language (e.g. for German you would copy ``blenderbim.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 **BlenderBIM Translations**
55+
panel.
56+
57+
How to add new translation strings
58+
----------------------------------
59+
60+
When you have new strings to translate, press the **Parse BlenderBIM strings to
61+
.pot** button. This detects strings in the source code using regex patterns and
62+
writes out to the ``blenderbim.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 ``blenderbim/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.

src/blenderbim/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Learn how to model a small building and create simple architectural plans, secti
4242
devs/hello_world
4343
devs/running_tests
4444
devs/writing_docs
45+
devs/translations
4546
devs/undo_system
4647
devs/system_support
4748
devs/ux_guidelines

0 commit comments

Comments
 (0)