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

[BUG] Internationalization not working #772

Open
abbyhu2000 opened this issue Sep 8, 2021 · 5 comments
Open

[BUG] Internationalization not working #772

abbyhu2000 opened this issue Sep 8, 2021 · 5 comments
Labels
backlog Issues that the Dashboards core team is interested in pursuing but are not yet on the roadmap bug Something isn't working i18n Internationalization related Issues and PRs

Comments

@abbyhu2000
Copy link
Member

Describe the bug
When changing the locale config from English to Chinese in the opensearch_dashboards.yml file, the application does not change language to Chinese but still showing the default language English.

To Reproduce
Steps to reproduce the behavior:

  1. Go to opensearch_dashboards.yml file
  2. Scroll down to 'i18n.locale'
  3. Input "zh-CN"
  4. Restart server and refresh the browser

Expected behavior
Language for the Opensearch Dashboard should be changed from the default language English to Chinese as the comments saying "supported languages are the following: English - en, by default, Chinese -zh-CN" in the yml file.

Screenshots
Screen Shot 2021-09-08 at 4 49 36 PM

Additional context
Legacy application includes the supported translation functions in the X-pack folder, so we do not have access to it.

request:
curl 'http://localhost:5603/uev/translations/zh-cn.json' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://localhost:5603/uev/app/discover' -H 'Connection: keep-alive' -H 'Cookie:xxxxx' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'

resp:
{"locale":"zh-CN","messages":{}}
@abbyhu2000 abbyhu2000 added bug Something isn't working untriaged labels Sep 8, 2021
@abbyhu2000
Copy link
Member Author

One possible solution is to create a translation plugin.

@tmarkley tmarkley added backlog Issues that the Dashboards core team is interested in pursuing but are not yet on the roadmap and removed untriaged labels Sep 23, 2021
@tmarkley tmarkley added the i18n Internationalization related Issues and PRs label Oct 19, 2021
schleuss pushed a commit to schleuss/OpenSearch-Dashboards that referenced this issue Feb 23, 2022
@schleuss
Copy link

I'm working on translating opensearch-dashboard to pt-BR and I had the same problem when deploying.

Investigating the problem, I noticed that the translation files are not loaded

Req:
curl 'http://localhost:5603/translations/pt-BR.json' 

Res:
{"locale":"pt-BR","messages":{}}

Through debugging I've verified that the translation files are not found when executing the script src/legacy/server/i18n/index.ts

The cause of this problem is the format of the expression passed to the globby lib

Changing the code, adding '**' before the I18N_RC the problem was fixed

  const translationPaths = await Promise.all([
    getTranslationPaths({
      cwd: fromRoot('.'),
      glob: `**/${I18N_RC}`,
    }),
    ...(config.get('plugins.paths') as string[]).map((cwd) =>
      getTranslationPaths({ cwd, glob: I18N_RC })
    ),
    ...(config.get('plugins.scanDirs') as string[]).map((cwd) =>
      getTranslationPaths({ cwd, glob: `**/${I18N_RC}` })
    ),
    getTranslationPaths({
      cwd: fromRoot('../opensearch-dashboards-extra'),
      glob: `**/${I18N_RC}`,
    }),
  ]);

After finding the I18N_RC files (.i18nrc.json), the translations are loaded from the json

In my case, the scripts/i18n_integrate tool did not add the files in this configuration. I had to do this manually.

{
  ...
  "translations": []
}

I can't tell if it's another problem, or something I forgot to do.

PR: #1276

@gaoyan0204
Copy link

how to customize the language conversion plug-in?

@schleuss
Copy link

Here is an example of translation to pt-BR..

https://github.com/schleuss/opensearch-dashboard-i18n-ptbr

But i've found some translations issues. Some opensearrch UI components are not working properly.

@joshuarrrr
Copy link
Member

We've created the i18n OpenSearch Dashboards plugin to provide this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issues that the Dashboards core team is interested in pursuing but are not yet on the roadmap bug Something isn't working i18n Internationalization related Issues and PRs
Projects
None yet
Development

No branches or pull requests

5 participants