Skip to content

Commit 1212c47

Browse files
committed
docs: Various updates to the i18n documentation based on recent work
Update the documentation with the latest knowledge and workflow based on how we actually ended up doing the Spanish translation. Signed-off-by: Philip Withnall <[email protected]>
1 parent 217e340 commit 1212c47

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

docs/i18n.md

+36-26
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ which covers the backend of kolibri-explore-plugin.
1515
At a high level, translatable strings are extracted from Python, JavaScript and
1616
Vue files, and are collated into several files:
1717
* `kolibri_explore_plugin/locale/en/LC_MESSAGES/django.po`
18+
* `kolibri_explore_plugin/locale/en/LC_MESSAGES/ek-components-messages.csv`
1819
* `kolibri_explore_plugin/locale/en/LC_MESSAGES/kolibri_explore_plugin-messages.csv`
1920
* `kolibri_explore_plugin/locale/en/LC_MESSAGES/template-ui-messages.csv`
2021

@@ -23,60 +24,69 @@ This extraction process is done by running `yarn i18n-extract`.
2324
They are in several files because they are extracted from the Django backend and
2425
the different node frontend modules separately.
2526

26-
These files are checked into git, even though they are generated mechanically
27-
from the source code, so that translators or external translation tools can pick
28-
them up at any time, without having to run kolibri-tools on the code.
27+
Translations are done (currently manually) on the strings in the CSV files, to
28+
produce JSON files for each locale. A translation workflow which has worked in
29+
the past is to import the CSV files into Google Docs, translate them
30+
collaboratively, download the results as CSV files (being careful with the
31+
column headers; see commit e7819e3d3d1747632253fe683bb876970955d40b), then run
32+
`yarn i18n-download-translations` to convert the translated CSV files to JSON.
2933

30-
Translations are done (currently manually), and the results committed to git as:
34+
For this to work, each CSV file must contain `Identifier` and `Translation`
35+
columns, named exactly that. It may contain other columns (they are ignored),
36+
and the filename may be anything ending in `.csv`.
37+
38+
**Note:** Currently the translated strings from the
39+
`ek-components-messages.json` and `template-ui-messages.json` files must also be
40+
copied into `kolibri_explore_plugin.app-messages.json` in all locales. (For
41+
example, see commit 8ae264cb83d3b7d5fa19effb82e9772a49f9c751.) This is because
42+
Kolibri only automatically loads `kolibri_explore_plugin.app-messages.json` in
43+
webpack.
44+
45+
The results are committed to git as:
3146
* `kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/django.po`
47+
* `kolibri_explore_plugin/locale/en/LC_MESSAGES/ek-components-messages.json`
3248
* `kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/kolibri_explore_plugin.app-messages.json`
3349
* `kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/template-ui-messages.json`
3450

35-
CSV versions of the JSON files are also available for review. The CSV versions
36-
may be imported into Google Docs, collaboratively translated, and then downloaded
37-
again; the following step will automatically convert them back to JSON.
38-
3951
The translated files for Django now need to be compiled to a machine readable
40-
form. This is done by `yarn i18n-download-translations`. (The naming is because,
41-
in Kolibri, this step downloads updated translations from a translation website
42-
before compiling them --- we do not currently do that in kolibri-explore-plugin.)
52+
form. This is also done by `yarn i18n-download-translations`. (The naming is
53+
because, in Kolibri, this step downloads updated translations from a translation
54+
website before compiling them — we do not currently do that in
55+
kolibri-explore-plugin.)
4356

4457
It compiles the Django messages to the following file:
4558
* `kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/django.mo`
4659

4760
This is loaded by Django to provide backend translations.
4861

49-
Secondly, it converts any local CSV files (`kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/*.csv`
50-
to JSON files, allowing for translation to be done in Google Docs via the CSV.
51-
For this to work, the CSV file must contain `Identifier` and `Translation`
52-
columns, named exactly that. It may contain other columns (they are ignored),
53-
and the filename may be anything ending in `.csv`.
54-
5562
It also generates the following two files, which contain information about the
5663
locale (such as its name and currency and date formats). They are for use with
5764
the node [`intl`](https://www.npmjs.com/package/intl) and
5865
[`vue-intl`](https://www.npmjs.com/package/vue-intl) packages:
5966
* `kolibri_explore_plugin/assets/src/intl-locale-data.js`
6067
* `kolibri_explore_plugin/assets/src/vue-intl-locale-data.js`
6168

62-
The frontend loads the installed source JSON files (such as
63-
`kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/kolibri_explore_plugin.app-messages.json`)
64-
at runtime. It does this by looking for them using a well-known name in
69+
The frontend loads the installed source JSON file
70+
(`kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/kolibri_explore_plugin.app-messages.json`)
71+
at runtime. It does this by looking for it using a well-known name in
6572
`LOCALE_PATHS`, then the `WebpackBundleHook.frontend_messages()` function
66-
injects the contents of the JSON files into the frontend JavaScript with a call
67-
to `kolibriCoreAppGlobal.registerLanguageAssets()` to register them with the
68-
translation functions.
73+
injects the contents of the JSON file into the frontend JavaScript with a call
74+
to `kolibriCoreAppGlobal.registerLanguageAssets()` to register it with the
75+
translation functions. The frontend will not load other JSON files, such as
76+
`template-ui-messages.json`.
6977

7078
Configuration
7179
---
7280

7381
Internationalisation configuration is in two places:
7482
* `kolibri_explore_plugin/locale/language_info.json`
75-
* `setup.cfg`
83+
* `pyproject.toml`/`setup.cfg`
7684

7785
The JSON file contains the list of languages which we want kolibri-explore-plugin
7886
translated to. It’s in a format needed by kolibri-tools documented
7987
[here](https://kolibri-dev.readthedocs.io/en/develop/i18n.html#adding-a-newly-supported-language).
8088

81-
`setup.cfg` is needed to point kolibri-tools at the right directories for
82-
extracting and compiling translatable strings.
89+
`pyproject.toml` is needed to point kolibri-tools at the right directories for
90+
extracting and compiling translatable strings. Older versions of kolibri-tools
91+
looked at `setup.cfg` for the same information; we are porting to
92+
`pyproject.toml` though.

0 commit comments

Comments
 (0)