mirror of
https://github.com/akuker/RASCSI.git
synced 2024-09-11 18:56:58 +00:00
Flesh out webapp localization readme (#578)
This commit is contained in:
parent
f5a9f32019
commit
9385483624
@ -53,25 +53,59 @@ We use the Flask-Babel library and Flask/Jinja2 extension for i18n.
|
|||||||
|
|
||||||
It uses the 'pybabel' command line tool for extracting and compiling localizations.
|
It uses the 'pybabel' command line tool for extracting and compiling localizations.
|
||||||
Activate the Python venv in src/web/ to use it:
|
Activate the Python venv in src/web/ to use it:
|
||||||
|
```
|
||||||
$ cd src/web/
|
$ cd src/web/
|
||||||
$ source venv/bin/activate
|
$ source venv/bin/activate
|
||||||
$ pybabel --help
|
$ pybabel --help
|
||||||
|
```
|
||||||
|
|
||||||
To create a new localization, it needs to be added to accept_languages in
|
To create a new localization, it needs to be added to the LANGAUGES constant in
|
||||||
the get_locale() method, and also to localizer.cpp in the RaSCSI C++ code.
|
web/settings.py. To localize messages coming from the RaSCSI backend, update also code in
|
||||||
|
raspberrypi/localizer.cpp in the RaSCSI C++ code.
|
||||||
|
|
||||||
Once this is done, follow the steps in the [Flask-Babel documentation](https://flask-babel.tkte.ch/#translating-applications)
|
Once this is done, follow the steps in the [Flask-Babel documentation](https://flask-babel.tkte.ch/#translating-applications)
|
||||||
to generate the messages.po for the new language.
|
to generate the messages.po for the new language.
|
||||||
|
|
||||||
Updating an existing messages.po is also covered above.
|
Updating the strings in an existing messages.po is also covered above.
|
||||||
|
|
||||||
When you are ready to contribute new or updated localizations, use the same Gitflow Workflow as used for any code contributions to submit PRs against the develop branch.
|
When you are ready to contribute new or updated localizations, use the same Gitflow Workflow as used for any code contributions to submit PRs against the develop branch.
|
||||||
|
|
||||||
|
### Working with PO files
|
||||||
|
|
||||||
|
See the [GNU gettext documentation](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html) for an introduction to the PO file format.
|
||||||
|
|
||||||
|
We make heavy use of __python-format__ for formatting, for instance:
|
||||||
|
```
|
||||||
|
#: file_cmds.py:353
|
||||||
|
#, python-format
|
||||||
|
msgid "%(file_name)s downloaded to %(save_dir)s"
|
||||||
|
msgstr "Laddade ner %(file_name)s till %(save_dir)s"
|
||||||
|
```
|
||||||
|
|
||||||
|
There are also a few instances of formatting in JavaScript:
|
||||||
|
```
|
||||||
|
#: templates/index.html:381
|
||||||
|
msgid "Server responded with code: {{statusCode}}"
|
||||||
|
msgstr "Servern svarade med kod: {{statusCode}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
And with html tags:
|
||||||
|
```
|
||||||
|
#: templates/index.html:304
|
||||||
|
#, python-format
|
||||||
|
msgid ""
|
||||||
|
"Emulates a SCSI DaynaPORT Ethernet Adapter. <a href=\"%(url)s\">Host "
|
||||||
|
"drivers and configuration required</a>."
|
||||||
|
msgstr ""
|
||||||
|
"Emulerar en SCSI DaynaPORT ethernet-adapter. <a href=\"%(url)s\">Kräver "
|
||||||
|
"drivrutiner och inställningar</a>."
|
||||||
|
```
|
||||||
|
|
||||||
### (Optional) See translation stats for a localization
|
### (Optional) See translation stats for a localization
|
||||||
Install the gettext package and use msgfmt to see the translation progress.
|
Install the gettext package and use msgfmt to see the translation progress.
|
||||||
|
```
|
||||||
$ sudo apt install gettext
|
$ sudo apt install gettext
|
||||||
$ cd src/web/
|
$ cd src/web/
|
||||||
$ msgfmt --statistics translations/sv/LC_MESSAGES/messages.po
|
$ msgfmt --statistics translations/sv/LC_MESSAGES/messages.po
|
||||||
215 translated messages, 1 untranslated message.
|
215 translated messages, 1 untranslated message.
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user