OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

[BUG] Internationalization not working

Open abbyhu2000 opened this issue 3 years ago • 5 comments

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 avatar Sep 08 '21 23:09 abbyhu2000

One possible solution is to create a translation plugin.

abbyhu2000 avatar Sep 08 '21 23:09 abbyhu2000

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: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1276

schleuss avatar Feb 24 '22 12:02 schleuss

how to customize the language conversion plug-in?

gaoyan0204 avatar Jul 14 '22 00:07 gaoyan0204

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.

schleuss avatar Jul 15 '22 17:07 schleuss

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

joshuarrrr avatar Oct 04 '22 21:10 joshuarrrr