See #840 (comment)
The problem
Currently, the kolibri-tools i18n-extract-messages build utility is called multiple times by kolibri-explore-plugin, once for each component (template-ui, ek-components, the app). This was implemented in commit d4d678d because the utility only supports one --namespace/--searchPath argument pair.
This setup extracts the messages from each component into a CSV file named after the component, e.g. ek-components-messages.csv. This is then translated and committed as ek-components-messages.json.
At runtime, the webpack_asset tag (e.g. {% webpack_asset 'kolibri.core.default_frontend' %} in base.html) generates some inline JavaScript which calls kolibriCoreAppGlobal.registerLanguageAssets() on the translated messages, which are loaded from the JSON file and injected inline into the page in that call.
There is only a webpack asset for kolibri_explore_plugin.app, there is no webpack asset for ek-components or template-ui. This means that none of the runtime loading code actually loads the ek-components/template-ui messages in, and hence they are not translated at runtime.
There is prior art in Kolibri for how to handle translations from a sub-package, in the form of its kolibri-common package, which contains some common UI elements (and translations). It’s hooked in to the generated JSON file by kolibri-tools i18n-extract-messages: when passed an additional --namespace and --searchPath argument (for kolibri-common), it will extract messages from that namespace too, and bung them into the same output file.
This can be seen by doing ack -l searchPlaceholder in kolibri-explore-plugin vs ack -l resourcesUnavailable in Kolibri. The latter appears in kolibri/locale/*/LC_MESSAGES/kolibri.core.default_frontend-messages.json, whereas the former does not (and that means it’s not translated at runtime).
The fix
We need to revert d4d678d and instead change kolibri-tools i18n-extract-messages to support multiple --namespace/--searchPath pairs.
A short term workaround would be to manually move all the messages from {ek-components,template-ui}-messages.json into kolibri_explore_plugin.app-messages.json. But that would have to be repeated every time the strings are re-extracted or the translation is updated.
See #840 (comment)
The problem
Currently, the
kolibri-tools i18n-extract-messagesbuild utility is called multiple times by kolibri-explore-plugin, once for each component (template-ui, ek-components, the app). This was implemented in commit d4d678d because the utility only supports one--namespace/--searchPathargument pair.This setup extracts the messages from each component into a CSV file named after the component, e.g.
ek-components-messages.csv. This is then translated and committed asek-components-messages.json.At runtime, the
webpack_assettag (e.g.{% webpack_asset 'kolibri.core.default_frontend' %}inbase.html) generates some inline JavaScript which callskolibriCoreAppGlobal.registerLanguageAssets()on the translated messages, which are loaded from the JSON file and injected inline into the page in that call.There is only a webpack asset for
kolibri_explore_plugin.app, there is no webpack asset for ek-components or template-ui. This means that none of the runtime loading code actually loads the ek-components/template-ui messages in, and hence they are not translated at runtime.There is prior art in Kolibri for how to handle translations from a sub-package, in the form of its kolibri-common package, which contains some common UI elements (and translations). It’s hooked in to the generated JSON file by
kolibri-tools i18n-extract-messages: when passed an additional--namespaceand--searchPathargument (for kolibri-common), it will extract messages from that namespace too, and bung them into the same output file.This can be seen by doing
ack -l searchPlaceholderin kolibri-explore-plugin vsack -l resourcesUnavailablein Kolibri. The latter appears inkolibri/locale/*/LC_MESSAGES/kolibri.core.default_frontend-messages.json, whereas the former does not (and that means it’s not translated at runtime).The fix
We need to revert d4d678d and instead change
kolibri-tools i18n-extract-messagesto support multiple--namespace/--searchPathpairs.A short term workaround would be to manually move all the messages from
{ek-components,template-ui}-messages.jsonintokolibri_explore_plugin.app-messages.json. But that would have to be repeated every time the strings are re-extracted or the translation is updated.