-
Notifications
You must be signed in to change notification settings - Fork 133
fix(i18n): extract translations on plugins
folder
#1589
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
fix(i18n): extract translations on plugins
folder
#1589
Conversation
Thanks for the pull request, @igobranco! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
plugins
folderplugins
folder
@igobranco I added you to the triage team so tests will run automatically for you going forward. This PR seems to have stuck jobs, can you push an empty commit or similar to see if it kicks off the checks again? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1589 +/- ##
==========================================
+ Coverage 93.07% 93.50% +0.43%
==========================================
Files 1092 1128 +36
Lines 21617 22925 +1308
Branches 4577 4858 +281
==========================================
+ Hits 20120 21436 +1316
+ Misses 1431 1421 -10
- Partials 66 68 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thanks @e0d |
@openedx/2u-tnl this is ready for review. Thanks! |
package.json
Outdated
@@ -11,7 +11,7 @@ | |||
], | |||
"scripts": { | |||
"build": "fedx-scripts webpack", | |||
"i18n_extract": "fedx-scripts formatjs extract", | |||
"i18n_extract": "formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js*", |
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.
Thanks @igobranco for the pull request and really sorry for the delay. Somehow I didn't include this pull request on my todo list.
I'll test locally, but one question. I noticed that you're setting the file to become ./temp/babel-plugin-formatjs/Default.messages.json
, what's reason for this specific file choice and why did you mention it explicitly?
Are you aware of the specifics of fedx-scripts formatjs extract
? What features do we expect to lose when removing the fedx-scripts
meta-script?
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.
Thanks @igobranco for your contribution, please check the comments and let me know what do you think.
package.json
Outdated
@@ -11,7 +11,7 @@ | |||
], | |||
"scripts": { | |||
"build": "fedx-scripts webpack", | |||
"i18n_extract": "fedx-scripts formatjs extract", | |||
"i18n_extract": "formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js*", |
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.
I've checked the fedx-scripts
and I think there's a better solution because the fedx-scripts
accepts additional arguments and I'd like to ask you to try it first:
"i18n_extract": "formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js*", | |
"i18n_extract": ""i18n_extract": "fedx-scripts formatjs extract plugins/**/*.js*", |
We might need to add quotes, I'm unsure whether bash is running here or not:
"i18n_extract": "formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js*", | |
"i18n_extract": ""i18n_extract": "fedx-scripts formatjs extract 'plugins/**/*.js*'", |
Please check:
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.
@OmarIthawi
Yes, I checked when I open this PR.
That is why I included ./temp/babel-plugin-formatjs/Default.messages.json
because behind the scenes the fedx-scripts
is using that.
In general the problem is that the fedx-scripts
formatjs
don't allow to add additional source folders. But probably this isn't the idea of fedx-scripts
of having too much custom options, just a basic framework for different Open edX frontend packages.
So I think this resume the execution, where each step executes the next one:
npm run i18n_extract
fedx-scripts formatjs extract
that is installed onnode_modules/@openedx/frontend-build/bin/fedx-scripts.js
that adds those commonArgs to the next processnode_modules/@formatjs/cli/bin/formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore src/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- src/**/*.js*
but this command don't include theplugins
folder where this repository has additional code.
So my proposal is to replace the fedx-scripts formatjs extract
executing a lower level command directly that also includes the plugins
folder.
If you execute this PR before and after you will an increase on the strings to be translated, 145
strings on the branch that I opened the PR.
$ npm run i18n_extract
> @edx/[email protected] i18n_extract
> formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js*
[@formatjs/cli] [WARN] [FormatJS CLI] Duplicate message id: "authoring.proctoring.alert.error", but the `description` and/or `defaultMessage` are different.
$ grep '"id"' temp/babel-plugin-formatjs/Default.messages.json | wc -l
1860
I can't make it run with your proposal:
package.json changed to:
"i18n_extract": "fedx-scripts formatjs extract plugins/**/*.js*",
Execute and output:
$ npm run i18n_extract
> @edx/[email protected] i18n_extract
> fedx-scripts formatjs extract plugins/**/*.js*
Running with resolved config:
/home/ibranco/projects/openedx/frontend-app-authoring/node_modules/@openedx/frontend-build/config/babel.config.js
[@formatjs/cli] [WARN] Error: Error processing file plugins/course-apps/calculator/package.json
Debug Failure. Output generation failed
Yes, it passes the arguments, but because the fedx-scripts will add more arguments, then the real formatjs executed will be kind of different!
a434a17
to
35d164c
Compare
@OmarIthawi I reviewed the command. Changed to: "i18n_extract": "formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js* {src,plugins}/**/messages.ts", To include the I tested and it has increased the extraction to $ npm run i18n_extract && grep '"id"' temp/babel-plugin-formatjs/Default.messages.json | wc -l
> @edx/[email protected] i18n_extract
> formatjs extract --format node_modules/@openedx/frontend-build/lib/formatter.js --ignore {src,plugins}/**/*.json --out-file ./temp/babel-plugin-formatjs/Default.messages.json -- {src,plugins}/**/*.js* {src,plugins}/**/messages.ts
[@formatjs/cli] [WARN] [FormatJS CLI] Duplicate message id: "authoring.proctoring.alert.error", but the `description` and/or `defaultMessage` are different.[@formatjs/cli] [WARN] [FormatJS CLI] Duplicate message id: "course-authoring.library-authoring.component.advanced.olx-save", but the `description` and/or `defaultMessage` are different.[@formatjs/cli] [WARN] [FormatJS CLI] Duplicate message id: "course-authoring.library-authoring.create-library", but the `description` and/or `defaultMessage` are different.[@formatjs/cli] [WARN] [FormatJS CLI] Duplicate message id: "course-authoring.library-authoring.publish.error", but the `description` and/or `defaultMessage` are different.
2376 I tested and now I could translate the "Select problem type", the others should also work... Nevertheless, the problem types aren't going to be translated, someone has been creative:
|
Thanks @igobranco for the debugging in and the additional information.
I think that makes sense, a more appropriate and acceptable change is to add an argument to the Which would be more sensible and avoid hidden assumptions. The issue with removing |
@OmarIthawi to resolve part of the "problem", related to my last comment, I just opened a new PR #1801 that renames the message.ts files to message.js. |
@OmarIthawi I opened a new PR openedx/frontend-build#650 for frontend-build with your suggestion to add that |
fixes #1588
Description
This pull request fixes the extract translations process for the
plugins
folder.This increases the messages that are going to be extracted, making it possible to translate more of this application.
This PR is useful for "Operators" that use Studio and Course authoring MFE on a different language than English.
Testing instructions
Run the extract_translations on master and on this PR: