Skip to content
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

chore(translations): Add missing i18n #17525

Merged
merged 10 commits into from
Nov 27, 2021
Merged

Conversation

hbruch
Copy link
Contributor

@hbruch hbruch commented Nov 23, 2021

SUMMARY

This PR adds the missing *.ts to 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 the pot file updated.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Nov 23, 2021

Codecov Report

Merging #17525 (9cb3759) into master (2e29f36) will decrease coverage by 0.07%.
The diff coverage is 78.57%.

❗ Current head 9cb3759 differs from pull request most recent head 787009d. Consider uploading reports for the commit 787009d to get more accurate results
Impacted file tree graph

@@            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              
Flag Coverage Δ
hive 81.60% <ø> (ø)
mysql 82.02% <ø> (ø)
postgres 82.03% <ø> (ø)
presto ?
python 82.38% <ø> (-0.15%) ⬇️
sqlite 81.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/actions/sqlLab.js 58.69% <0.00%> (ø)
...c/SqlLab/components/TemplateParamsEditor/index.tsx 88.88% <ø> (ø)
...t-frontend/src/dashboard/actions/dashboardState.js 28.80% <ø> (ø)
...t-frontend/src/dashboard/components/SliceAdder.jsx 76.62% <ø> (ø)
...dashboard/components/SliceHeaderControls/index.tsx 75.38% <0.00%> (ø)
...ilters/FilterBar/FilterControls/FilterControls.tsx 82.69% <ø> (ø)
...e/components/controls/SelectAsyncControl/index.tsx 80.48% <0.00%> (ø)
...c/filters/components/Select/SelectFilterPlugin.tsx 81.05% <ø> (ø)
...eModal/DatabaseConnectionForm/CommonParameters.tsx 94.44% <ø> (ø)
...set-frontend/src/views/CRUD/welcome/ChartTable.tsx 73.49% <ø> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e29f36...787009d. Read the comment docs.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few first pass comments. Big thanks for this PR, amazing catch!

return t(LAST_VIEWED, entity.time_delta_humanized);
return t('Viewed %s', entity.time_delta_humanized);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, this whole section seems to rely on time_delta_humanized and changed_on_delta_humanized being localized, which apparently is not the case:

grafik

For other tables/columns, this seems to be handled differently:
grafik

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

const welcomeTableLabels: Record<WelcomeTable, string> = {
[WelcomeTable.Charts]: t('charts'),
[WelcomeTable.Dashboards]: t('dashboards'),
[WelcomeTable.Recents]: t('recents'),
[WelcomeTable.SavedQueries]: t('saved queries'),
};

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(),);
};

return t(LAST_MODIFIED, entity.changed_on_delta_humanized);
return t('Modified %s', entity.changed_on_delta_humanized);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

superset-frontend/src/views/CRUD/welcome/EmptyState.tsx Outdated Show resolved Hide resolved
@hbruch
Copy link
Contributor Author

hbruch commented Nov 23, 2021

Another topic for the developer tutorial: ${t('string-to-translate')} in backticks seems not be extracted by babel. Not sure, if this is a bug or expected behavior, which needs to be worked around in superset.

Further, I find some translations in .po files (e.g. Pie Chart in 'sl/LC_MESSAGES/messages.po' or 'zh/LC_MESSAGES/messages.po') which I don't find in the superset project and which are, in consequence, not extracted to the .pot file

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.

@dkrat7
Copy link
Contributor

dkrat7 commented Nov 24, 2021

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.

@hbruch
Copy link
Contributor Author

hbruch commented Nov 26, 2021

@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?

@villebro
Copy link
Member

@hbruch I think it's just a flaky test. I restarted the test, let's see if that resolves it

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, awesome work!

@@ -19,6 +19,7 @@
[jinja2: superset/**/templates/**.html]
[javascript: superset-frontend/src/**.js]
[javascript: superset-frontend/src/**.jsx]
[javascript: superset-frontend/src/**.ts]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhaoyongjie let's make sure translations are properly handled after monorepo lands!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@villebro I have rebase master on stage-2 PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add plugins and packages to babel.cfg

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks @zhaoyongjie !

@villebro villebro merged commit 6604a6a into apache:master Nov 27, 2021
@zhaoyongjie zhaoyongjie self-requested a review November 27, 2021 13:04
@hbruch hbruch deleted the missing_i18n branch December 8, 2021 21:40
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XXL 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants