fix: Changing language doesn't affect echarts charts#31751
fix: Changing language doesn't affect echarts charts#31751villebro merged 18 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Fix Detected |
|---|---|---|
| Unsafe Dynamic Module Import ▹ view | ✅ | |
| Missing Locale Fallback ▹ view | ✅ | |
| Missing locale state fallback ▹ view | ✅ |
Need a new review? Comment
/korbit-reviewon this PR and I'll review your latest changes.Korbit Guide: Usage and Customization
Interacting with Korbit
- You can manually ask Korbit to review your PR using the
/korbit-reviewcommand in a comment at the root of your PR.- You can ask Korbit to generate a new PR description using the
/korbit-generate-pr-descriptioncommand in any comment on your PR.- Too many Korbit comments? I can resolve all my comment threads if you use the
/korbit-resolvecommand in any comment on your PR.- Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
- Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.
Customizing Korbit
- Check out our docs on how you can make Korbit work best for you and your team.
- Customize Korbit for your organization through the Korbit Console.
Feedback and Support
| })); | ||
|
|
||
| const localeObj = useSelector((state: ExplorePageState) => state?.common?.locale); | ||
| const lang = require('echarts/lib/i18n/lang' + localeObj.toUpperCase()).default; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
pomegranited
left a comment
There was a problem hiding this comment.
Thank you for submitting this PR @jpchev , you beat me to it :)
With just a few small changes, this is working well for me.
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
👍 This change is working great! Thank you @jpchev :)
- I tested this by combining it with #31692 to test changing languages while viewing and editing the Pie Chart echart. I verified that this change ensures the "Inv" and "All" buttons on that echart are now translated as expected.
- I read through the code
translate.echarts.mp4
|
@villebro might be most qualified to look at this one, if he has time. That said, there are some failing tests that could use attention, and a more descritive PR title could help too :D |
sorry for the cryptic title, I've put the title of the issue it fixes. I know it's not recommended, but I don't know how to dynamically import a js file without using 'require'. |
| const locale = useSelector( | ||
| (state: ExplorePageState) => state?.common?.locale ?? 'en', | ||
| ).toUpperCase(); | ||
| try { | ||
| const lang = require(`echarts/lib/i18n/lang${locale}`).default; | ||
| registerLocale(locale, lang); | ||
| } catch (e) { | ||
| console.warn(`Locale ${locale} not supported in ECharts`); | ||
| } | ||
|
|
There was a problem hiding this comment.
@jpchev I think we need to use dynamic imports instead, but they're tricky to use in React. I tried a few ways and wasn't able to get it to render properly, so am asking the bot:
@dosu how do we refactor this to ensure we await the import and registerLocale calls before calling init below?
There was a problem hiding this comment.
Reply is here: #30131 (comment)
But it doesn't work :(
There was a problem hiding this comment.
Yes, I tried something similar, without success. That's why I went for require.
|
@pomegranited I fixed almost all the checks, there is this one left which I don't how to treat https://github.com/apache/superset/actions/runs/12949242972/job/36119814005?pr=31751 do you have an idea? It seems there are errors also on files not impacted by changes in this PR,
|
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/package-lock.json
Outdated
There was a problem hiding this comment.
Could you revert these changes? I don't think they're needed.
|
@pomegranited I've pushed again my code from scratch, in order to resolve the conflict on superset-frontend/package-lock.json I think it needs again to be approved |
bba5d7a to
0c8010c
Compare
e19e66c to
e4bdb28
Compare
@sadpandajoe thank you, I've rebased and now all checks pass. |
|
@villebro do you know if there is anything I'm missing on this PR to have it reviewed? |
|
@geido can you please have a look at this PR? |
villebro
left a comment
There was a problem hiding this comment.
LGTM except for the dev dependency being in regular dependencies
| "lodash": "^4.17.21", | ||
| "dayjs": "^1.11.13" | ||
| "dayjs": "^1.11.13", | ||
| "@types/react-redux": "^7.1.10" |
There was a problem hiding this comment.
I think this should be in devDependencies
|
@jpchev my apologies, for some reason it appears to require having the type package under regular dependencies 🤔 My apologies (not sure why this is, I need to investigate this in more detail..) Anyway, please revert that change and I'll merge when CI is green again. |
|
@villebro ok, thank you, I reverted the change in order to have the type under |
Co-authored-by: Giampaolo Capelli <giampaolo.capelli@docaposte.fr> (cherry picked from commit 78efb62)
SUMMARY
this is to propagate the current locale up to the echarts configuration.
fixes: #30131
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
switch the locale and verify that charts have the correct locale (for example in months name and in buttons)