@@ -15,6 +15,7 @@ which covers the backend of kolibri-explore-plugin.
15
15
At a high level, translatable strings are extracted from Python, JavaScript and
16
16
Vue files, and are collated into several files:
17
17
* ` kolibri_explore_plugin/locale/en/LC_MESSAGES/django.po `
18
+ * ` kolibri_explore_plugin/locale/en/LC_MESSAGES/ek-components-messages.csv `
18
19
* ` kolibri_explore_plugin/locale/en/LC_MESSAGES/kolibri_explore_plugin-messages.csv `
19
20
* ` kolibri_explore_plugin/locale/en/LC_MESSAGES/template-ui-messages.csv `
20
21
@@ -23,60 +24,69 @@ This extraction process is done by running `yarn i18n-extract`.
23
24
They are in several files because they are extracted from the Django backend and
24
25
the different node frontend modules separately.
25
26
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.
29
33
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:
31
46
* ` kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/django.po `
47
+ * ` kolibri_explore_plugin/locale/en/LC_MESSAGES/ek-components-messages.json `
32
48
* ` kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/kolibri_explore_plugin.app-messages.json `
33
49
* ` kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/template-ui-messages.json `
34
50
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
-
39
51
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.)
43
56
44
57
It compiles the Django messages to the following file:
45
58
* ` kolibri_explore_plugin/locale/${locale}/LC_MESSAGES/django.mo `
46
59
47
60
This is loaded by Django to provide backend translations.
48
61
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
-
55
62
It also generates the following two files, which contain information about the
56
63
locale (such as its name and currency and date formats). They are for use with
57
64
the node [ ` intl ` ] ( https://www.npmjs.com/package/intl ) and
58
65
[ ` vue-intl ` ] ( https://www.npmjs.com/package/vue-intl ) packages:
59
66
* ` kolibri_explore_plugin/assets/src/intl-locale-data.js `
60
67
* ` kolibri_explore_plugin/assets/src/vue-intl-locale-data.js `
61
68
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
65
72
` 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 ` .
69
77
70
78
Configuration
71
79
---
72
80
73
81
Internationalisation configuration is in two places:
74
82
* ` kolibri_explore_plugin/locale/language_info.json `
75
- * ` setup.cfg `
83
+ * ` pyproject.toml ` / ` setup.cfg `
76
84
77
85
The JSON file contains the list of languages which we want kolibri-explore-plugin
78
86
translated to. It’s in a format needed by kolibri-tools documented
79
87
[ here] ( https://kolibri-dev.readthedocs.io/en/develop/i18n.html#adding-a-newly-supported-language ) .
80
88
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