pomegranited commented on code in PR #31751:
URL: https://github.com/apache/superset/pull/31751#discussion_r1926225103
##########
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx:
##########
@@ -123,10 +127,20 @@ function Echart(
getEchartInstance: () => chartRef.current,
}));
+ 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`);
+ }
+
Review Comment:
@jpchev I think we need to use [dynamic
imports](https://medium.com/@shubham3480/dynamic-imports-in-react-3e3e7ad1d210)
instead, but they're [tricky to use in
React](https://stackoverflow.com/a/58244389). 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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]