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

[2.x manual backport]Change the locale dynamically by adding &i18n-locale to URL (#7686) #7781

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

ananzh
Copy link
Member

@ananzh ananzh commented Aug 21, 2024

Backport PR:

#7686

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

…cale to URL (opensearch-project#7686)

Backport PR:
opensearch-project#7686

* Change the locale dynamically by adding &i18n-locale to URL

The main issue was the inability to dynamically change the locale in OpenSearch
Dashboards. Currently we need to update config file and i18nrc.json.

This PR allows  users to switch to a different locale (e.g., from English to Chinese)
by appending or modifying the 'i18n-locale' parameter in the URL.

* getAndUpdateLocaleInUrl: If a non-default locale is found, this function reconstructs
the URL with the locale parameter in the correct position.
* updated the ScopedHistory class, allowing it to detect locale changes and trigger reloads
as necessary.
* modify the i18nMixin, which sets up the i18n system during server startup, to register
all available translation files during server startup, not just the current locale.
* update the uiRenderMixin to accept requests for any registered locale and dynamically
load and cache translations for requested locales.

---------

Signed-off-by: Anan Zhuang <ananzh@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Copy link
Contributor

❌ Invalid Changelog Heading

The '## Changelog' heading in your PR description is either missing or malformed. Please make sure that your PR description includes a '## Changelog' heading with proper spelling, capitalization, spacing, and Markdown syntax.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 88.73239% with 8 lines in your changes missing coverage. Please review.

Project coverage is 63.90%. Comparing base (06da6ce) to head (67c9d0d).
Report is 7 commits behind head on 2.x.

Files Patch % Lines
src/core/public/locale_helper.ts 82.35% 3 Missing ⚠️
src/legacy/server/i18n/index.ts 0.00% 3 Missing ⚠️
src/core/public/osd_bootstrap.ts 88.88% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              2.x    #7781      +/-   ##
==========================================
+ Coverage   63.86%   63.90%   +0.03%     
==========================================
  Files        3656     3657       +1     
  Lines       81064    81122      +58     
  Branches    12901    12915      +14     
==========================================
+ Hits        51772    51837      +65     
+ Misses      26124    26114      -10     
- Partials     3168     3171       +3     
Flag Coverage Δ
Linux_1 30.07% <0.00%> (-0.03%) ⬇️
Linux_2 55.98% <60.56%> (+0.02%) ⬆️
Linux_3 40.49% <0.00%> (-0.04%) ⬇️
Linux_4 31.46% <39.68%> (-0.01%) ⬇️
Windows_1 30.09% <0.00%> (-0.03%) ⬇️
Windows_2 55.93% <60.56%> (+0.02%) ⬆️
Windows_3 40.49% <0.00%> (-0.04%) ⬇️
Windows_4 31.46% <39.68%> (-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.

@ananzh ananzh merged commit f2faa0a into opensearch-project:2.x Aug 22, 2024
65 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants