-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
Changing languages doesn't affect echarts charts. #30131
Comments
I found a similar unsolved discussion: How to change locale in echarts [1]. Additionally, there is a closed issue that might be relevant: [SIP-60] Proposal to extend i18n support to charts [2]. The proposed solution includes extending i18n support to charts, which might help with translating the 'All' and 'Inv' buttons. To ensure that the 'All' and 'Inv' buttons in a Pie chart are translated when changing the language in Superset, you need to add the corresponding translation entries in the msgid "All"
msgstr ""
msgid "Inv"
msgstr "" After adding these entries, you can provide the translations for each language in the respective msgid "All"
msgstr "Все"
msgid "Inv"
msgstr "Инв" This will ensure that the 'All' and 'Inv' buttons are translated appropriately when the language is changed in Superset [3][4]. |
Well, seems like I just need to change one line in superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx |
To get the current locale in the Superset frontend, you can access it from the Redux state. The current locale is stored under Here's how you can modify your code in import { useEffect, useRef } from 'react';
import { useSelector } from 'react-redux';
import { use, init, EChartsType } from 'echarts/core';
import { ExplorePageState } from 'src/explore/types';
const Echart = () => {
const divRef = useRef<HTMLDivElement>(null);
const chartRef = useRef<EChartsType | null>(null);
const locale = useSelector((state: ExplorePageState) => state?.common?.locale);
useEffect(() => {
if (!divRef.current) return;
if (!chartRef.current) {
chartRef.current = init(divRef.current, undefined, { locale });
}
// Your existing event handlers and options setup
}, [locale]);
return <div ref={divRef} />;
};
export default Echart; This code retrieves the current locale from the Redux state and passes it to the |
Thanks for looking into this, and hoping Dosu is setting you on the right path. I would assume there are LOTS of pieces in plugins that are not translated correctly. If you wind up opening a PR that fixes this, maybe it'll prove out as a reusable pattern to fix such things in other plugins, too. 🤞 |
Well,
|
Bug description
When you switch language in Superset, some charts still have untranslated buttons.
For example Pie chart has 'All' and 'Inv' buttons, that are always on English
How to reproduce the bug
Screenshots/recordings
Language set to Russian, buttons are on English:
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: