diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-12-21 16:05:07 +0100 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-01-13 11:36:46 +0100 |
commit | c34da1e09876f6b053ee50acf29538625a800d3a (patch) | |
tree | f84815537ba087d57c992a54447d506fda324ef5 /ogcp/cfg/ogcp.json | |
parent | 4777fcaee68ba5aca9b4270d6946ca6e62934cfb (diff) |
Add language configuration and Spanish translation
This commits configures and sets up flask-babel and adds Spanish po
file. Flask-babel is already a dependency so this commits no needs to
add it.
Users can edit ogcp.json to choose between English or Spanish. After
changing the language in the configuration file, users must restart ogcp
service.
Instructions to generate translation files, inspired by
https://flask-babel.tkte.ch/:
1. Download ogcp source code.
git clone git://git.soleta.eu/ogCP /path/to/ogcp
2. Create a python virtual environment.
python3 -m venv /path/to/new/venv
3. Activate the virtual environment.
source /path/to/new/venv/bin/activate
4. Install dependencies to the virtual environment.
cd /path/to/ogcp
pip3 install -r requirements.txt
5. Extract ogcp strings.
cd /path/to/ogcp/ogcp
pybabel extract -F babel.cfg -k _l -o messages.pot .
NOTE: "-k _l" is needed to extract strings which use lazy
translations.
6. Create or update translation files.
a. Create translation file. This example creates a french translation
file.
pybabel init -i messages.pot -d translations -l fr
b. Update translation files. You need to do this when ogcp strings
change and want to update current supported languages.
pybabel update -i messages.pot -d translations
7. Edit the translations .po file as needed. Example route:
/path/to/ogcp/ogcp/translations/fr/LC_MESSAGES/messages.po.
8. Compile translations.
pybabel compile -d translations
9. Launch ogcp and check the translations.
cd /path/to/ogcp
pip3 install -r requirements.txt
10. Commit and push .po files with translation changes.
Diffstat (limited to 'ogcp/cfg/ogcp.json')
-rw-r--r-- | ogcp/cfg/ogcp.json | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/ogcp/cfg/ogcp.json b/ogcp/cfg/ogcp.json index 3f8a82c..0a47a07 100644 --- a/ogcp/cfg/ogcp.json +++ b/ogcp/cfg/ogcp.json @@ -2,6 +2,7 @@ "IP": "127.0.0.1", "PORT": 8888, "API_TOKEN": "c3fe7bb0395747ec42a25df027585871", + "LANG": "en", "USERS": [ { "USER": "admin", |