Update README

This commit is contained in:
Guðni Már Gilbert 2022-11-27 09:35:21 +00:00
parent d90859e6a6
commit 4a93288353
1 changed files with 30 additions and 10 deletions

View File

@ -8,9 +8,9 @@ Firmware support is controlled by the ``LANG_MODE`` define in the configuration,
### Required tools ### Required tools
Python 3 with the ``regex``, ``pyelftools`` and ``polib`` modules as well as ``gettext`` and ``dos2unix``. On a debian-based distribution, install the required packages with: Python 3 is the main tool. To install the required packages run the following command in the `lang` folder:
sudo apt-get install python3-regex python3-pyelftools python3-polib gettext dos2unix pip install -r requirements.txt
### Main summary ### Main summary
@ -26,8 +26,8 @@ High-level tools:
* ``config.sh``: Language selection/configuration * ``config.sh``: Language selection/configuration
* ``fw-build.sh``: Builds the final multi-language hex file into this directory * ``fw-build.sh``: Builds the final multi-language hex file into this directory
* ``fw-clean.sh``: Cleanup temporary files left by ``fw-build.sh`` * ``fw-clean.sh``: Cleanup temporary files left by ``fw-build.sh``
* ``update-pot.sh``: Extract internationalized strings from the sources and place them inside ``po/Firmware.pot`` * ``update-pot.py``: Extract internationalized strings from the sources and place them inside ``po/Firmware.pot``
* ``update-po.sh``: Refresh po file/s with new translations from the main pot file. * ``update-po.py``: Refresh po file/s with new translations from the main pot file.
Lower-level tools: Lower-level tools:
@ -47,6 +47,28 @@ This step is already performed for you when using ``build.sh`` or ``PF-build.sh`
### Updating an existing translation ### Updating an existing translation
#### How to update `.pot` file
Run
python update-pot.py
to regenerate ``po/Firmware.pot`` and verify that the annotation has been picked up correctly. You can stop here if you only care about the annotation.
#### How to update `.po` file
To update a single `.po` file:
python update-po.py --file Firmware_XY.po
This will propagate the new strings to your language. This will merge the new strings, update references/annotations as well as marking unused strings as obsolete.
To update all .po files at once:
python update-po.py --all
#### Typo or incorrect translation in existing text #### Typo or incorrect translation in existing text
If you see a typo or an incorrect translation, simply edit ``po/Firmware_XY.po`` and make a pull request with the changes. If you see a typo or an incorrect translation, simply edit ``po/Firmware_XY.po`` and make a pull request with the changes.
@ -65,17 +87,15 @@ to preview all translations as formatted on the screen.
If some text is missing, but there is no reference text in the po file, you need to refresh the translation file by picking up new strings and annotations from the template. If some text is missing, but there is no reference text in the po file, you need to refresh the translation file by picking up new strings and annotations from the template.
Run ``./update-po.sh po/Firmware_XY.po`` to propagate the new strings to your language. This will merge the new strings, update references/annotations as well as marking unused strings as obsolete. See section [how to update .po file](#how-to-update-.po-file) to update the translations, then proceed as for [typo or incorrect translation](#typo-or-incorrect-translation-in-existing-text).
Update the translations, then proceed as for [typo or incorrect translation](#typo-or-incorrect-translation-in-existing-text).
### Fixing an incorrect screen annotation or english text ### Fixing an incorrect screen annotation or english text
The screen annotations as well as the original english text is extracted from the firmware sources. **Do not change the main pot file**. The ``pot`` and ``po`` file contains the location of the annotation to help you fix the sources themselves. The screen annotations as well as the original english text is extracted from the firmware sources. **Do not change the main pot file**. The ``pot`` and ``po`` file contains the location of the annotation to help you fix the sources themselves.
Run ``./update-pot.sh`` to regenerate ``po/Firmware.pot`` and verify that the annotation has been picked up correctly. You can stop here if you only care about the annotation. * See section [how to update .pot file](#how-to-update-.pot-file) to update the reference file.
Run ``./update-po.sh po/Firmware_XY.po`` otherwise to propagate the annotation to your language, then proceed as for [typo or incorrect translation](#typo-or-incorrect-translation-in-existing-text). * To sync one language: See section [how to update .po file](#how-to-update-.po-file); to propagate the annotation from the `.pot` file to your language, then proceed as for [typo or incorrect translation](#typo-or-incorrect-translation-in-existing-text).
### Adding a new language ### Adding a new language
@ -83,7 +103,7 @@ Each language is assigned a two-letter ISO639-1 language code.
The firmware needs to be aware of the language code. It's probably necessary to update the "Language codes" section in ``Firmware/language.h`` to add the new code as a ``LANG_CODE_XY`` define as well as add the proper language name in the function ``lang_get_name_by_code`` in ``Firmware/language.c``. The firmware needs to be aware of the language code. It's probably necessary to update the "Language codes" section in ``Firmware/language.h`` to add the new code as a ``LANG_CODE_XY`` define as well as add the proper language name in the function ``lang_get_name_by_code`` in ``Firmware/language.c``.
It is a good idea to ensure the translation template is up-to-date before starting to translate. Run ``./update-pot.sh`` to regenerate ``po/Firmware.pot`` if possible. It is a good idea to ensure the translation template is up-to-date before starting to translate. See section [how to update .pot file](#how-to-update-.pot-file).
Copy ``po/Firmware.pot`` to ``po/Firmware_XY.po``. The *same* language code needs to be used for the "Language" entry in the metadata. Other entries can be customized freely. Copy ``po/Firmware.pot`` to ``po/Firmware_XY.po``. The *same* language code needs to be used for the "Language" entry in the metadata. Other entries can be customized freely.