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

fix(localization): pybabel doesn't extract plural forms from frontend #22507

Merged
merged 1 commit into from
Dec 31, 2022

Conversation

artemonsh
Copy link
Contributor

@artemonsh artemonsh commented Dec 22, 2022

SUMMARY

Currently there is an issue with the plural forms on the frontend. At first, let's take a look at this code:

tn(
'Drop a column here or click',
'Drop columns here or click',
multi ? 2 : 1,
)

It is expected that while extracting these strings into .po file using babel-update.sh they should look like this:

msgid "Drop a column here or click"
msgid_plural "Drop columns here or click"
msgstr[0] ""
msgstr[1] ""

or this:

msgid "Drop a column here or click"
msgid_plural "Drop columns here or click"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""

depending on the number of plural forms in the language. For instance, English and French have 2 plural forms and Russian has 3.

But in reality none of the .po files contain plural forms. For instance, .po file for French translations, which has 2 plural forms

"Plural-Forms: nplurals=2; plural=(n > 1)\n"
does not contain the desired syntax for translating both of forms:
msgid "Drop a column here or click"
msgstr "Supprimer une colonne ici ou cliquer"

The solution to this issue is simple and is offered in this PR. This is the only official source I have found to prove my changes, but I found same solutions on some russian websites.

TESTING INSTRUCTIONS

Go to the root directory of superset and run ./scripts/babel-update.sh.

ADDITIONAL INFORMATION

@artemonsh artemonsh changed the title fix(localization): Babel does not extract plural forms from frontend fix(localization): pybabel does not extract plural forms from frontend Dec 22, 2022
@artemonsh artemonsh changed the title fix(localization): pybabel does not extract plural forms from frontend fix(localization): pybabel doesn't extract plural forms from frontend Dec 22, 2022
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 and confirmed to work as expected.

@@ -45,7 +45,7 @@ pybabel extract \
--sort-output \
--copyright-holder=Superset \
--project=Superset \
-k _ -k __ -k t -k tn -k tct .
-k _ -k __ -k t -k tn:1,2 -k tct .
Copy link
Member

Choose a reason for hiding this comment

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

Bycatch - we probably don't need -k tct here as I don't believe we even have such a translator function, but I suppose it doesn't matter that much.

@villebro villebro merged commit 64496e8 into apache:master Dec 31, 2022
@artemonsh artemonsh deleted the FIX_babel_plural_forms branch January 14, 2023 10:58
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 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/XS 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plural forms are not compiled from .tsx files to messages.pot for translation
3 participants