-
Notifications
You must be signed in to change notification settings - Fork 272
feat: properly translate the table chart #724
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/superset/superset-ui/4wuaoxiie |
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 the quick fix
d2c8300
to
688a66e
Compare
688a66e
to
ab58087
Compare
ab58087
to
b5ced07
Compare
17f65bd
to
f254ef6
Compare
Codecov Report
@@ Coverage Diff @@
## master #724 +/- ##
==========================================
+ Coverage 24.14% 24.35% +0.20%
==========================================
Files 338 340 +2
Lines 7607 7636 +29
Branches 921 929 +8
==========================================
+ Hits 1837 1860 +23
- Misses 5699 5703 +4
- Partials 71 73 +2
Continue to review full report at Codecov.
|
22440f7
to
6a14cbf
Compare
.translate(key) | ||
.ifPlural(plural, key) | ||
.fetch(plural, num, ...args); | ||
} |
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.
Allow tn('key', 2)
so we don't have to provide the key twice (t('key', 'key', 2)
).
This is AWESOME. Thank you!!! Will review in detail asap. |
|
||
export const PAGE_SIZE_OPTIONS = formatSelectOptions<number>([[0, t('All')], 10, 20, 50, 100, 200]); | ||
addLocaleData(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.
Had to inject the locale data here because it was used by the controlPanel
module before it can be imported. Ideally this should be in a more stable place, e.g., Plugin.setup(...)
or Plugin.contructor(...)
, but that requires refactoring controlPanel
to be loaded async. Let's leave it to a future PR.
871d6ab
to
89bb55f
Compare
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! 🎉
One potential/hypothetical future improvement (just for discussion) might be to namespace translations (by plugin key, for example). In this (awesome!) PR, it appears that the first plugin to register a translation string wins. Which is a huge improvement! But I could see some theoretical case where two or more plugins attempt to provide translations for the same string. Those translations might be better or worse than one another, or have some different context. Having them prefer their own translations and fall back to others might prevent some headaches. Anyway, we can bolt that on later, if the situation ever arises.
This is great work. Thanks for tackling it!
Thanks! I agree we should probably have some kind of namespacing and preferably even enable that for other parts of Superset, too. But before we tackle i18n more seriously, I don't feel like spending too much time on it. |
🏆 Enhancements
Enhance the
superset-ui/translation
package to support adding client side translations on demand, paving the road for dynamic plugin loading.Using the table chart as an example.
cc @suddjian @rusackas @kristw @stuarthu