Skip to content

Commit b40ed52

Browse files
docs: add documentation for new translation workflow
1 parent 4244c38 commit b40ed52

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

TRANSLATIONS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Translation Workflow
2+
3+
This project uses `pybabel` for translations, completely managed through `poethepoet` (poe) tasks.
4+
The translation files are packaged internally within `src/edit_python_pe/locale/` so they are automatically included in PyPI wheel distributions.
5+
6+
## General Workflow
7+
8+
### 1. Generating or Updating `.po` files (`makemessages`)
9+
When you add new `_("...")` strings in the source code, run:
10+
```bash
11+
uv run poe makemessages
12+
```
13+
This automatically extracts all translation strings from `src/edit_python_pe/` into `messages.pot` and **updates all existing locales** (e.g. `es`, `fr`, etc.) with the new strings, keeping existing translations intact.
14+
15+
### 2. Compiling `.mo` files (`compilemessages`)
16+
After you finish translating the `.po` files, you must compile them into the binary `.mo` format so the application can read them.
17+
```bash
18+
uv run poe compilemessages
19+
```
20+
This command compiles all languages in the `locale` directory simultaneously.
21+
22+
---
23+
24+
## Adding a New Language
25+
26+
If you want to add an entirely new language (for example, German `de`), use the `messages:init` command:
27+
```bash
28+
uv run poe messages:init --lang de
29+
```
30+
This extracts the strings and initializes the completely new directory `src/edit_python_pe/locale/de/LC_MESSAGES/messages.po`.
31+
32+
---
33+
34+
## Auto-Translating via Google Translate
35+
36+
The project includes an automatic translation script (`bin/translate.py`) powered by `deep-translator`. If you wish to automatically translate an existing `.po` file (e.g. for French `fr`), run:
37+
```bash
38+
uv run poe messages:translate --lang fr
39+
```
40+
*Note: This will overwrite empty `msgstr` entries in the `.po` file using Google Translate. Remember to run `poe compilemessages` after doing this to generate the updated `.mo` file!*

0 commit comments

Comments
 (0)