-
Notifications
You must be signed in to change notification settings - Fork 323
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 i18next and config for i18n of UI #2254
Conversation
d98f5cf
to
be75a05
Compare
be75a05
to
44867d8
Compare
package.json
Outdated
{ | ||
"dependencies": { | ||
"@types/react": "^18.0.25", | ||
"i18next": "^22.0.6", | ||
"i18next-browser-languagedetector": "^7.0.1", | ||
"react-i18next": "^12.0.0" | ||
} | ||
} |
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.
This should be inside the existing package.json
file inside the 'web` directory.
Just add these to the file:
"i18next": "^22.0.6",
"i18next-browser-languagedetector": "^7.0.1",
"react-i18next": "^12.0.0"
and run npm i
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.
This file along with the lock file should then be deleted.
web/src/i18n.js
Outdated
} | ||
}); | ||
|
||
export default i18n; |
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.
You can apply formatting by running npm run eslint-fix
that will cleanup newline issues like this.
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.
ran eslint with npx, think I resolved this
web/src/i18n.js
Outdated
@@ -0,0 +1,46 @@ | |||
import i18n from 'i18next'; |
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.
Can you make this a TypeScript file? End it with the *.ts
instead of the JavaScript extension.
44867d8
to
1f2506c
Compare
Codecov Report
@@ Coverage Diff @@
## main #2254 +/- ##
=========================================
Coverage 77.01% 77.01%
Complexity 1166 1166
=========================================
Files 222 222
Lines 5307 5307
Branches 424 424
=========================================
Hits 4087 4087
Misses 747 747
Partials 473 473 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
0a368ca
to
5c6e024
Compare
@phixMe reverting to |
18d2687
to
5997e68
Compare
When the translation is longer than the original, the effect is not great, unfortunately. But there's no reason to assume these "translations" (from Google) are worth keeping. @julienledem @mobuchowski would you please review? |
web/src/i18n.js
Outdated
jobs: 'Pracy', | ||
and: 'i', | ||
datasets: 'Zestawy Danych' | ||
} |
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.
I think we need to agree on run, job, dataset translations. IMO
RUN: wykonanie (as in "wykonanie zadania")
JOB: zadanie
DATASET: zbiór danych
I think only wykonanie
might be controversial - it translates more to execution
, but I don't have better idea. Bieg
or przebieg
make sense only as the sport IMO.
then:
docs_link: Dokumentacja API
latest_tab: OSTATNIE WYKONANIE
history tab: HISTORIA WYKONAŃ
location: LOKALIZACJA
empty_title: Brak dostępnych informacji o wykonaniu
empty_body: Spróbuj dodać kilka wykonań dla tego zadania
search: Wyszukiwanie
jobs: Zadania
and: i
datasets: Zbiory Danych
Still, translations of "computer concepts" will always sound awkward in Polish for me.
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.
thank you, @mobuchowski . @pawel-big-lebowski @JDarDagran @tnazarew WDYT?
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.
I'd say wykonanie
sounds more natural to me. We shouldn't be so strict about translating this one to one. Job and dataset are just 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.
Thanks, @mobuchowski and @JDarDagran . I've revised the translations.
Does it add an option to switch language or does it force a translation based on something like browser language? I think it would be great to have language switcher if we do something like it. |
@mobuchowski i18next does support a language-switcher setup, but that route is a bit more labor-intensive. |
52dac32
to
3745a7e
Compare
@phixMe To translate the text in web/src/components/lineage/Lineage.tsx I did a workaround that required changing the tsconfig.json to set 'noImplicitAny' to 'false'. The initial problem was that there doesn't seem to be any way to use the |
"webpack-merge": "^4.2.1", | ||
"i18next": "^22.0.6", | ||
"i18next-browser-languagedetector": "^7.0.1", | ||
"react-i18next": "^12.0.0" |
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.
There should be an update to the lock file in this directory.
@@ -23,6 +23,8 @@ import MqEmpty from '../core/empty/MqEmpty' | |||
import MqText from '../core/text/MqText' | |||
import Node from './components/node/Node' | |||
import ParentSize from '@visx/responsive/lib/components/ParentSize' | |||
import { useTranslation } from 'react-i18next' | |||
import i18next from '../../i18n' |
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.
@merobi-hub I think you don't want to be importing this here. This should be your type issue for no-implicit-any
<FormControl variant='outlined' className={classes.formControl}> | ||
<Select | ||
value={i18next.resolvedLanguage} | ||
onChange={event => { | ||
changeLanguage(event.target.value as string) | ||
}} | ||
input={<MqInputBase />} | ||
> | ||
<MenuItem key={'en'} value={'en'}> | ||
{'en'} | ||
</MenuItem> | ||
<MenuItem key={'es'} value={'es'}> | ||
{'es'} | ||
</MenuItem> | ||
<MenuItem key={'fr'} value={'fr'}> | ||
{'fr'} | ||
</MenuItem> | ||
<MenuItem key={'pl'} value={'pl'}> | ||
{'pl'} | ||
</MenuItem> | ||
</Select> | ||
</FormControl> |
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.
How is this looking now? Can you add a screenshot to the PR?
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.
@@ -11,7 +11,8 @@ | |||
"lib": ["es2016", "es2017", "dom"], | |||
"skipLibCheck": true, | |||
"esModuleInterop": true, | |||
"downlevelIteration": true | |||
"downlevelIteration": true, | |||
"resolveJsonModule": true | |||
}, | |||
"include": ["./src/**/*"], | |||
"exclude": ["./src/__tests__/*"] |
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.
Can we do without these config changes now? Implicit any in TypeScript is not the best rule to have disabled.
web/webpack.dev.js
Outdated
@@ -22,7 +22,7 @@ const webpackDev = { | |||
}, | |||
proxy: { | |||
'/api': { | |||
target: `http://${process.env.MARQUEZ_HOST || 'localhost'}:${process.env.MARQUEZ_PORT || 8080}/`, | |||
target: `http://${process.env.MARQUEZ_HOST || 'localhost'}:${process.env.MARQUEZ_PORT || 5000}/`, |
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.
I think we don't want this change committed.
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.
where's the facepalm emoji? (reverted this)
Signed-off-by: Michael Robinson <merobi@gmail.com>
…to ui/add-i18next Signed-off-by: Michael Robinson <merobi@gmail.com>
4820353
to
1f322b1
Compare
Signed-off-by: Michael Robinson <merobi@gmail.com>
Signed-off-by: Michael Robinson <merobi@gmail.com>
Signed-off-by: Michael Robinson <merobi@gmail.com>
b5ea8ea
to
854d863
Compare
Signed-off-by: Michael Robinson <merobi@gmail.com>
@phixMe I believe this is RFR again. I added some missing translations I found, caught up to the new Events route and reverted the configuration changes. See the screenshots for what it looks like. |
# Conflicts: # web/package-lock.json # web/src/components/header/Header.tsx # web/src/components/jobs/JobDetailPage.tsx # web/src/components/jobs/RunInfo.tsx # web/src/components/jobs/Runs.tsx # web/src/components/lineage/Lineage.tsx # web/src/components/search/SearchPlaceholder.tsx # web/src/components/sidenav/Sidenav.tsx # web/src/i18n/config.ts # web/src/types/i18next.d.ts # web/tsconfig.json
Signed-off-by: Michael Robinson <merobi@gmail.com>
@phixMe This is RFR. Added a reload after a language change and fixed the reloading issue so the new language setting persists. |
Signed-off-by: Michael Robinson <merobi@gmail.com>
a1d7c8e
to
be600e7
Compare
Signed-off-by: Michael Robinson <merobi@gmail.com>
be600e7
to
287ba68
Compare
OK, now this is actually RFR @phixMe |
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.
Looks great @merobi-hub. Thanks for the contribution.
src="https://raw.githubusercontent.com/MarquezProject/marquez/main/web/src/img/iconSearchArrow.svg" | ||
width={'30px'} | ||
/> | ||
<SVG src='../../img/iconSearchArrow.svg' width={'30px'} /> |
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.
@merobi-hub, this reverts the change for #2280
Signed-off-by: Michael Robinson merobi@gmail.com
Problem
Internationalization is strongly recommended by the LFAI (in the CII Silver Badge). The UI is not currently internationalized.
Closes: #ISSUE-NUMBER
Solution
This change adds i18next, configures it, and edits the text to make use of the tool's translation capabilities.
Checklist
CHANGELOG.md
with details about your change under the "Unreleased" section (if relevant, depending on the change, this may not be necessary).sql
database schema migration according to Flyway's naming convention (if relevant)