-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kolibri-tools: Accept multiple --namespace/--searchPath arguments #11357
kolibri-tools: Accept multiple --namespace/--searchPath arguments #11357
Conversation
At the 11th hour I’ve just noticed that this might need further changes, to put all the extracted messages into a single CSV file rather than one per namespace. I’ll look at that tomorrow. Sorry for missing that earlier. The rest of the changes are ready to be reviewed at a high level though. |
Build Artifacts
|
This is needed when a plugin has more than one sub-package which contains translatable strings. All the strings from all the packages need to be pulled into the `*-messages.json` file which is injected into the frontend output — but currently only at most one sub-package is supported. For Kolibri itself, this is kolibri-common. The kolibri-explore-plugin, however, has at least two sub-packages. This commit changes the `--namespace` and `--searchPath` options to allow them to be specified multiple times. For example, `--namespace ek-components --searchPath ./packages/ek-components --namespace template-ui --searchPath ./packages/template-ui`. It shouldn’t change the behaviour when they are passed zero or one times, as before, so this change should be backwards-compatible. The strings from each namespace are still outputted into a per-namespace CSV file, with the assumption that the translation step (when CSVs are turned into JSON files) will combine them all into a single JSON file suitable for webpack to load. See endlessm/kolibri-explore-plugin#846 Signed-off-by: Philip Withnall <[email protected]>
550fd1c
to
f7442ef
Compare
Done. I had got mixed up in my head about whether all the strings from all namespaces are outputted to a single file (which is incorrect); it’s actually that they’re all outputted to per-namespace CSV files. That’s fine, and it’s not a behaviour change from the current kolibri-tools behaviour. Ready for review. |
This speeds up the i18n extraction process, but it cannot remove the need for the workaround from #846 where the per-namespace CSV files need to be combined into a single JSON file for webpack to load. Currently that’s done manually. This commit is still WIP as it needs a kolibri-tools version bump to be able to rely on the new behaviour, which is currently unmerged upstream at learningequality/kolibri#11357, and not in a release yet. Signed-off-by: Philip Withnall <[email protected]> Helps: #846
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look correct, and this doesn't seem to impact existing behaviour, so this seems fine to me!
Has been published to npm as next. |
Summary
This is needed when a plugin has more than one sub-package which contains translatable strings. All the strings from all the packages need to be pulled into the
*-messages.json
file which is injected into the frontend output — but currently only at most one sub-package is supported. For Kolibri itself, this is kolibri-common. The kolibri-explore-plugin, however, has at least two sub-packages.This commit changes the
--namespace
and--searchPath
options to allow them to be specified multiple times. For example,--namespace ek-components --searchPath ./packages/ek-components --namespace template-ui --searchPath ./packages/template-ui
. It shouldn’t change the behaviour when they are passed zero or one times, as before, so this change should be backwards-compatible.The strings from each namespace are still outputted into a per-namespace
CSV file, with the assumption that the translation step (when CSVs are
turned into JSON files) will combine them all into a single JSON file
suitable for webpack to load.
See endlessm/kolibri-explore-plugin#846
References
Reviewer guidance
vs
(This relies on running in kolibri-explore-plugin, as that’s the motivator for this fix.)
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)