-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e75b6c
commit b8eddc4
Showing
2 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
# Translation | ||
|
||
## Internationalization | ||
|
||
The Sketch Map Tool uses [Babel](https://babel.pocoo.org/en/latest/) through [Flask Babel](https://github.com/python-babel/flask-babel) for internationalization. | ||
It is configured ([babel.cfg](../babel.cfg)) to look for strings to be translated in all Jinja2 HTML templates. | ||
Text to be translated in Python files need to be manually selected and wrapped in a `gettext` function call (E.g. Error messages in `routes.py`). | ||
Please refer to to the official documentation of [Flask Babel](https://python-babel.github.io/flask-babel/index.html#translating-applications) regarding the process of translating the application. | ||
|
||
Additionally a function called N_ was added to mark strings for translation, this is mainly used in the context of errors, since they should not be translated in the error log, but need to be translated later when send to the users. If you want to raise a new Exception in the Code, please look at the already implemented examples. | ||
## Translation via Crowdin | ||
|
||
The Sketch Map Tool uses the platform [Crowdin](https://crowdin.com/) for translation. | ||
|
||
# Automatic Approach: | ||
Text marked for translation is send from GitHub to Crowdin via GitHub Action ([github-to-crowdin.yml](../.github/workflows/github-to-crowdin.yml)). The action triggers on push to `main`. | ||
|
||
The Sketch Map Tool uses crowdin to help as a platform for translations. To get the strings which need to be translated the github | ||
action [github-to-crowdin.yml](../.github/workflows/github-to-crowdin.yml) is used. It is executed once anything is pushed into origin/main. | ||
Translated text is send from Crowdin to GitHub via GitHub Action ([crowdin-to-github.yml](../.github/workflows/crowdin-to-github.yml)). The action triggers regularly and results in a PR when new translations are available. | ||
|
||
To get the translated strings from crowdin to github the github action [crowdin-to-github.yml](../.github/workflows/crowdin-to-github.yml) | ||
is used. It runs daily and opens a new pullrequest if new translation string where added. | ||
## Manual Translation | ||
|
||
> Note: Since Crowdin is used for translation following section is not longer relevant. | ||
# Manual Approach: | ||
Without the help of tools like crowdin, things would have to look like this: | ||
The basic process for translation on a local machine would look something like this: | ||
|
||
## Add a new translation | ||
### Add a new translation | ||
|
||
```bash | ||
pybabel extract -F config/babel.cfg -o messages.pot . | ||
pybabel init -i messages.pot -d sketch_map_tool/translations -l de | ||
pybabel compile -d sketch_map_tool/translations | ||
``` | ||
|
||
## Update an existing translation | ||
### Update an existing translation | ||
|
||
```bash | ||
cd sketch_map_tool | ||
pybabel extract -F config/babel.cfg -o messages.pot . | ||
pybabel update -i messages.pot -d sketch_map_tool/translations | ||
pybabel compile -d sketch_map_tool/translations | ||
``` | ||
|