Skip to content
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

Split .i18nrc across src, packages, and examples #8414

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

AMoo-Miki
Copy link
Collaborator

Description

Split .i18nrc across src, packages, and examples

Note: This is the first step in recursively looking for translations. These 3 will be the roots where i18n will recursively search.

Also:

  • Force validation of i18n even when no translations are available

Changelog

  • refactor: Split .i18nrc across src, packages, and examples

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.92%. Comparing base (4b56be5) to head (ac7150a).
Report is 31 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8414   +/-   ##
=======================================
  Coverage   60.92%   60.92%           
=======================================
  Files        3750     3751    +1     
  Lines       89104    89149   +45     
  Branches    13926    13935    +9     
=======================================
+ Hits        54284    54318   +34     
- Misses      31443    31451    +8     
- Partials     3377     3380    +3     
Flag Coverage Δ
Linux_1 28.85% <ø> (+0.02%) ⬆️
Linux_2 56.35% <ø> (-0.01%) ⬇️
Linux_3 37.73% <ø> (+<0.01%) ⬆️
Linux_4 29.96% <100.00%> (-0.01%) ⬇️
Windows_1 28.87% <ø> (+0.02%) ⬆️
Windows_2 56.30% <ø> (-0.01%) ⬇️
Windows_3 37.73% <ø> (+<0.01%) ⬆️
Windows_4 29.96% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AMoo-Miki AMoo-Miki force-pushed the fix-i18n-paths branch 2 times, most recently from 5e94c56 to d0dbf5c Compare October 1, 2024 09:31
@ashwin-pc ashwin-pc added the i18n Internationalization related Issues and PRs label Oct 1, 2024
Also:
* Force validation of i18n even when no translations are available
* Allow including translations in built artifacts

Signed-off-by: Miki <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this file is here, its likely because of our plugin scaffolding code. Lets modify it too to support generating the i18nrc code?

Copy link
Collaborator Author

@AMoo-Miki AMoo-Miki Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excludeFiles(
([] as string[]).concat(
answers.ui ? [] : 'public/**/*',
answers.ui && !answers.internal ? [] : ['translations/**/*', 'i18nrc.json'],

While generating a plugin, this piece decides if the i18n manifest and sample translation should be included or not.

  • If it is not a UI plugin, no i18n files will be included.
  • if a plugin is internal, no i18n files will be included.

data_explorer was probably generated as an external plugin and then they changes their minds.

Prior to this PR, everything in OSD shared one manifest and one translations folder. This PR splits them into 3 main groups of stuff under src, packages, and examples.
HOWEVER, my plan is to have i18n look through the 3 root folders recursively so src/core, and each internal plugin, package, and example can own its translations. I want to have some form of inheritance so common terms like Save and Save as need not be translated several times for each namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i create a new example or core or external plugin, how will this be updated? I think one of the reasons for keeping the i18nrc file in each plugin migt have been to make scaffolding easier (just speculation)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each external plugin will continue to own its own i18n manifest and translations. Each internal plugin, package, or example will eventually have their own manifest too, but with this PR, each will use the translations from the src, packages, or examples. Prior to this PR, they all had to pick from one central place.

There is logic which I think "imports" translations files and distributes them to the folder of each manifest based on the namesspaces defined in them. All of these will tie into each other when and if I get to next phase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this in a rewadme as a part of the change so that:

  1. Its clear to someone how translations works in OSD after this change.
  2. If you dont get to the next phase yourself, you still have it written down somewhere that someone can take your vision and execute it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A readme would be helpful - I really don't know how this works so harder to review

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +75 to +78
if (options.withTranslations) {
// control w/ --with-translations
await run(Tasks.CopyTranslations);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

"embeddableExamples": "embeddable_examples",
"expressionsExample": "expressions_example",
"multipleDataSourceExample": "multiple_data_source_examples",
"searchExamples": "search_examples",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the difference in total number of paths across these .i18nrc.json files due to adding some that were not added to the original ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A readme would be helpful - I really don't know how this works so harder to review

@AMoo-Miki AMoo-Miki merged commit f3f007a into opensearch-project:main Oct 3, 2024
66 of 67 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 3, 2024
Also:
* Force validation of i18n even when no translations are available
* Allow including translations in built artifacts

Signed-off-by: Miki <[email protected]>
(cherry picked from commit f3f007a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AMoo-Miki pushed a commit that referenced this pull request Oct 3, 2024
Also:
* Force validation of i18n even when no translations are available
* Allow including translations in built artifacts


(cherry picked from commit f3f007a)

Signed-off-by: Miki <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x distinguished-contributor i18n Internationalization related Issues and PRs v2.18.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants