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
add i18n support #6006
base: master
Are you sure you want to change the base?
add i18n support #6006
Conversation
I add i18n module but i need help to translate English, Chinese and French so on. So i need help language json file. |
If someone support language file, the language pack switching function on the UI should be added later, and the js-cookie package should be used to record the language pack used last time. |
I can translate to Portuguese :) |
Yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding it! Only thing I'd probably do is to keep it disabled until we have more internationalized strings not to have random translated words in the UI
|
||
i18n | ||
.use(initReactI18next) | ||
.use(LanguageDetector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this automatically enables the translation based on the browser? I think it may be better to leave it disabled until we have more strings translated (or under some feature flag / global settings)
"i18next": "^22.4.15", | ||
"i18next-browser-languagedetector": "^7.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From CI failure it seems it's missing the yarn.lock
changes, so you may need to re-run yarn
and push it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From CI failure it seems it's missing the
yarn.lock
changes, so you may need to re-runyarn
and push it :)
I pushed yarn.lock file.
Btw @gaecoli how are you doing the string extraction? Is it manually in this PR for now and still needs to be configured? |
There is no good idea for this, for me it can only be added manually. |
Sure, adding something like https://www.i18next.com/how-to/extracting-translations#2-using-an-extraction-tool to either automate the English strings extraction, or to have I haven't used |
@gabrieldutra Hello, I would like to ask, what should I do after I modify the source code, so that I can achieve the same code style as the original? Which front-end commands should I run? |
import LanguageDetector from "i18next-browser-languagedetector"; | ||
import { initReactI18next } from "react-i18next"; | ||
import en from "./locales/en.json"; | ||
import zh from "./locales/zh.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, with this zh
I've often seen it split into two. One for "Simplified Chinese", and one for "Traditional Chinese".
Should we have this named as one of them, to leave room for the other one at some future point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, with this
zh
I've often seen it split into two. One for "Simplified Chinese", and one for "Traditional Chinese".Should we have this named as one of them, to leave room for the other one at some future point?
OK. You are right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note is that importing languages like this will add all of them into the bundle, which may not be nice 😅.
It's possibly better to do an async import for those cases. https://www.i18next.com/how-to/add-or-load-translations had a bit of content on this.
Separate thing I was thinking about these days: Should we plan ahead how we will do the translations end-to-end, before committing anything? I don't know much about react-i18next
, I've used mostly react-intl, the main difference I saw so far is that the later also has a description
for each unformatted string. Considering Redash as an open-source / community effort and how LLMs are today, it may be a good thing to plan a flow which includes automatic generation of the translation files on every release. Then would count on the community only for reviewing/fixing eventual mistakes, in this case the description
would be useful for providing context and/or fixing the prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note is that importing languages like this will add all of them into the bundle, which may not be nice 😅.
It's possibly better to do an async import for those cases. https://www.i18next.com/how-to/add-or-load-translations had a bit of content on this.
Separate thing I was thinking about these days: Should we plan ahead how we will do the translations end-to-end, before committing anything? I don't know much about
react-i18next
, I've used mostly react-intl, the main difference I saw so far is that the later also has adescription
for each unformatted string. Considering Redash as an open-source / community effort and how LLMs are today, it may be a good thing to plan a flow which includes automatic generation of the translation files on every release. Then would count on the community only for reviewing/fixing eventual mistakes, in this case thedescription
would be useful for providing context and/or fixing the prompt.
Cool. It's a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note is that importing languages like this will add all of them into the bundle, which may not be nice 😅.
It's possibly better to do an async import for those cases. https://www.i18next.com/how-to/add-or-load-translations had a bit of content on this.
Separate thing I was thinking about these days: Should we plan ahead how we will do the translations end-to-end, before committing anything? I don't know much about
react-i18next
, I've used mostly react-intl, the main difference I saw so far is that the later also has adescription
for each unformatted string. Considering Redash as an open-source / community effort and how LLMs are today, it may be a good thing to plan a flow which includes automatic generation of the translation files on every release. Then would count on the community only for reviewing/fixing eventual mistakes, in this case thedescription
would be useful for providing context and/or fixing the prompt.
I haven't figured out which platform to host these mapping tables for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a data point - for a project many years ago - we had the project hosted on Launchpad, so it could make use of the translation infrastructure there.
One really cool benefit of that platform at the time was that if anyone, anywhere had translated the same string for any project on Launchpad (with compatible license) then the string was made available as a potential option.
It saved a lot of time for people, and made it easy to get pretty far with new language translations.
That being said, the company behind Launchpad (Canonical) have done some shady stuff in the past so I'm not really a fan of theirs... 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The possible use of LLM's for generating "first attempt" translations sounds like a useful idea too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The possible use of LLM's for generating "first attempt" translations sounds like a useful idea too.
Cool!
I could help translating to Chinese. How could I contribute? |
@gaecoli hey, any interest in continuing this PR? I think we need to split We also need to merge |
What type of PR is this?
Description
How is this tested?
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings (if there are UI changes)