chore(translations): Add missing i18n#17525
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17525 +/- ##
==========================================
- Coverage 77.01% 76.94% -0.08%
==========================================
Files 1049 1049
Lines 56671 56671
Branches 7851 7851
==========================================
- Hits 43648 43606 -42
- Misses 12770 12812 +42
Partials 253 253
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
villebro
left a comment
There was a problem hiding this comment.
A few first pass comments. Big thanks for this PR, amazing catch!
| // for Recent viewed items | ||
| if ('time_delta_humanized' in entity) { | ||
| return t(LAST_VIEWED, entity.time_delta_humanized); | ||
| return t('Viewed %s', entity.time_delta_humanized); |
There was a problem hiding this comment.
I'm not sure this change is necessary - I assume the variable value should be picked up here. Did you check if that's not the case?
There was a problem hiding this comment.
I verified, but using constants, the string was not extracted. gilbsgilbs/babel-plugin-i18next-extract#109 seems to confirm this, though the FAQ only speaks of variables, not constants.
There was a problem hiding this comment.
Oh interesting. Maybe I need to switch my local devenv to non-english to catch these, too. It's becoming apparent we need a proper developer tutorial for i18n, as it's obvious this is not being handled consistently across the app.
There was a problem hiding this comment.
To avoid duplication and risk of these falling out of sync, maybe we should introduce a similar localized translation mapping as I did in the previous PR:
superset/superset-frontend/src/views/CRUD/welcome/EmptyState.tsx
Lines 25 to 30 in bdc6a1d
Regarding time_delta_humanized, I'm pretty sure these are happening in the backend, let me look at those (I have a faint memory of when those were introduced).
There was a problem hiding this comment.
I wonder why time_delta_humanized and changed_on_delta_humanized are necessary? moment.fromNow seems to localize pretty well. Aren't time / changed_on / changed_on_utc avaible for every item? Code would become more compact:
const getEntityLastActionOn = (entity: ActivityObject) => {
if ('time' in entity) {
return t('Viewed %s', moment(entity.time).fromNow());
}
let time: number | string | undefined | null;
if ('changed_on' in entity) time = entity.changed_on;
if ('changed_on_utc' in entity) time = entity.changed_on_utc;
return t('Modified %s', time == null ? UNKNOWN_TIME : moment(time).fromNow(),);
};|
|
||
| if ('changed_on_delta_humanized' in entity) { | ||
| return t(LAST_MODIFIED, entity.changed_on_delta_humanized); | ||
| return t('Modified %s', entity.changed_on_delta_humanized); |
|
Another topic for the developer tutorial: Further, I find some translations in Finally, there are a some fragments, where messages are split in multiple sections, because in between there is an HTML element (e.g. ). These are somewhat harder to translate as the fragments on it's own sometimes are not meanigful. Not sure, if there is a better way to handle these. |
|
Regarding the additional translations in the 'sl/LC_MESSAGES/messages.po', I included the 'superset-ui' repo in extraction process (if I am right, that won't be problem anymore with monorepo). I also added some strings manually to the po file (I couldn't find the way to extract them with the babel). Thumbs up for properly solving i18n issues. |
|
@villebro I think I need your assistance here. I tried to figure out why the test cases fail but see no causing change in this PR. Wat might be the reason and how could I fix it? |
|
@hbruch I think it's just a flaky test. I restarted the test, let's see if that resolves it |
| [jinja2: superset/**/templates/**.html] | ||
| [javascript: superset-frontend/src/**.js] | ||
| [javascript: superset-frontend/src/**.jsx] | ||
| [javascript: superset-frontend/src/**.ts] |
There was a problem hiding this comment.
@zhaoyongjie let's make sure translations are properly handled after monorepo lands!
There was a problem hiding this comment.
I will add plugins and packages to babel.cfg
* Add *.ts to babel.cfg * Add missing i18n calls * Update pot file * Fix lint issues and review comment * Incorparate review feedback * Fix missing or non-extractable i18n calls * Update pot file * Fix syntax error in CommonParameters.tsx * Fix introduced issues


SUMMARY
This PR adds the missing
*.tsto babel.cfg, so messages in typescript files get extracted.Addditionally, a few missing i18n calls are added, some not extracted calls (i.e.
${t()}in backticks) rewritten, and thepotfile updated.ADDITIONAL INFORMATION