-
Notifications
You must be signed in to change notification settings - Fork 132
fix: rename messages.ts to messages.js to fix translation extraction #1801
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
Conversation
Renamed all messages.ts files to messages.js to fix the translation extraction process using fedx-scripts.js and formatjs tool. This change increases the number of extracted strings, improving localization.
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1801 +/- ##
==========================================
- Coverage 93.51% 93.48% -0.03%
==========================================
Files 1129 1129
Lines 22957 22867 -90
Branches 4862 4861 -1
==========================================
- Hits 21468 21378 -90
Misses 1421 1421
Partials 68 68 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Good catch! We definitely want to make sure we're not missing strings during the extraction process! I'm less sure that this is the approach we should use to fix it though. FormatJS supports message extraction from typescript files (docs), so I think a better solution would be to update the script in I think that would just mean updating this line '--', 'src/**/*.js*', to be '--', 'src/**/*.{j,t}s*', but I haven't tested that. |
@brian-smith-tcril Edit the:
Changed to case 'formatjs': {
const commonArgs = [
'--format', 'node_modules/@openedx/frontend-build/lib/formatter.js',
'--ignore', 'src/**/*.json',
'--ignore', 'src/**/*.d.ts',
'--out-file', './temp/babel-plugin-formatjs/Default.messages.json',
'--', 'src/**/*.{j,t}s*',
]; Then when I run it works and finds more translations: npm run i18n_extract && grep '"id"' temp/babel-plugin-formatjs/Default.messages.json | wc -l
> @edx/[email protected] i18n_extract
> fedx-scripts formatjs extract
Running with resolved config:
/home/ibranco/projects/openedx/frontend-app-authoring/node_modules/@openedx/frontend-build/config/babel.config.js
[@formatjs/cli] [WARN] [FormatJS CLI] Duplicate message id: "course-authoring.course-libraries.tab.home.description-no-links", 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.
2309 When I included the |
Replaced by openedx/frontend-build#650 |
Thanks for finding a better way. I definitely don't want to see those renamed. In fact we should do a mass-rename of all |
Renamed all messages.ts files to messages.js to fix the translation extraction process using fedx-scripts.js and formatjs tool. This change increases the number of extracted strings, improving localization.
Description
Currently the translation extract process uses the
fedx-scripts.js
that calls theformatjs
tool.The
fedx-scripts.js
assumes that all the i18n messages are on.js
file extension.By just changing the file extension on those files the extract translation process is fixed. Then more strings are sent to Transifex and this MFE is better localized for each language.
Before it extracts/ detect 1730 strings to be translated:
After extracts/ detect 2309 strings to be translated:
Supporting information
Execute the script to find how many strings are extracted:
Testing instructions
For example the message with id
authoring.problemEditor.selectType.title
wasn't extracted.With this PR it extracts, you can confirm by running:
grep "authoring.problemEditor.selectType.title" temp/babel-plugin-formatjs/Default.messages.json
To simulate the sent and download from Transifex you can execute:
Edit manually a language, example pt-pt locale, edit the file
src/i18n/messages/frontend-app-course-authoring/pt_PT.json
and add:This will fix the header when editing problems:

Other information
Related to: #1798