Skip to content

Commit 514997f

Browse files
committed
docs: i18n: update, consolidate in a README file
1 parent 1d0e271 commit 514997f

2 files changed

Lines changed: 59 additions & 41 deletions

File tree

i18n/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# i18n folder - working with translations
2+
3+
The app offers internationalization support using PO (gettext) files.
4+
5+
It's a popular format among translation professionals, and it has native support in Godot.
6+
7+
We keep the translation files in a separate repository. To contribute translations, please head to the [learn-gdscript-translations](https://github.com/GDQuest/learn-gdscript-translations) repository, where you'll find detailed instructions.
8+
9+
This folder contains the app's included translations (those that are complete or nearly complete) and scripts to manage them.
10+
11+
## How translations work in Godot and the app
12+
13+
The engine automatically translates UI nodes, while we need to wrap string literals in calls to the `tr()` function.
14+
15+
In your typical Godot project, you would preload translation resources through the project settings.
16+
17+
Instead, this app loads translations dynamically because we separate localization resources into several files per supported language. This applies to both POT files (translation templates) and translated PO files.
18+
19+
## Updating translation templates
20+
21+
The gettext translation format comes with two file extensions: POT for translation templates and PO for translations to a specific language. PO files derive from POT files, which allow us to track strings that changed between releases finely.
22+
23+
You generate the template POT files using a Python script included in this folder: extract.py.
24+
25+
To use the script, first create and activate a Python virtual environment. This allows you to install Python libraries this project needs without affecting your whole computer's Python installation.
26+
27+
Activate the environment and install dependencies with these commands (on Unix-like systems):
28+
29+
```sh
30+
python3 -m venv .venv
31+
source .venv/bin/activate
32+
pip install -r requirements.txt
33+
```
34+
35+
After doing that once, you can directly activate the environment:
36+
37+
```sh
38+
source .venv/bin/activate
39+
```
40+
41+
Then, run the extraction script:
42+
43+
```sh
44+
python i18n/extract.py
45+
```
46+
47+
You need to run it from the project's root directory. You then need to copy the POT files over to the [learn-gdscript-translations](https://github.com/GDQuest/learn-gdscript-translations) repository where we translate the content.
48+
49+
### Adding a new language to the app
50+
51+
To add a new language to the app, you need to:
52+
53+
1. Create a new subdirectory in the [learn-gdscript-translations](https://github.com/GDQuest/learn-gdscript-translations) repository with the two-letter code of your language. For example, `es/` for Spanish, `ru/` for Russian, or `zh/` for Chinese.
54+
2. For each POT file in the repository's root folder, create a derived PO translation file in your new subdirectory. You can use the program [Poedit](https://poedit.net/) to do so.
55+
3. In this repository, open the `TranslationManager.gd` script and add your new language code to its `SUPPORTED_LOCALES` constant. The order of languages in `SUPPORTED_LOCALES` defines the order they'll appear in the settings menu.
56+
57+
The app may not support your language's characters. If that is the case, please [open an issue](https://github.com/GDQuest/learn-gdscript/issues) on the repository to add the missing font files and font switching code.
58+
59+
**Important:** Currently, right-to-left languages like Arabic are not supported. The app needs to be ported to Godot 4 first, which will make it easier to add support for right-to-left languages.

i18n/working-with-translations.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)