OpenSearch-Dashboards
OpenSearch-Dashboards copied to clipboard
[BUG] Internationalization not working
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:
- Go to opensearch_dashboards.yml file
- Scroll down to 'i18n.locale'
- Input "zh-CN"
- 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
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":{}}
One possible solution is to create a translation plugin.
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
how to customize the language conversion plug-in?
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.
We've created the i18n OpenSearch Dashboards plugin to provide this functionality.