Skip to content

Check if plural forms are correct for languages. - #55327

Merged
potiuk merged 2 commits into
apache:mainfrom
potiuk:fix-plural-forms-for-translations
Sep 6, 2025
Merged

potiuk merged 2 commits into
apache:mainfrom
potiuk:fix-plural-forms-for-translations

Conversation

@potiuk

@potiuk potiuk commented Sep 6, 2025

Copy link
Copy Markdown
Member

It turned out, that some of the languages we had, did not have proper plural forms defined. There were few problems with it:

  • some languages had "default" form defined where they should have other forms
  • there were no check if language was missing in the plural forms, so new languages got the "default" form by - well - default.
  • we had no check in CI to check if languages are defined in the plural forms

This PR modifies the check-translations-completeness script and uses it as a prek (manual) hook to make it easier to get run, also to be able to run it in CI - it exits with non-zero exit only when there is a clear issue with configuration or call parameters, rather than when there are missing translations, it only prints green/red message summarizing the output.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@potiuk

potiuk commented Sep 6, 2025

Copy link
Copy Markdown
Member Author

It turned out that we had bad plural forms for:

We should fix that (I know in some languages it matters less than in others) but I guess we should fix those :) after we merge the fix.

In short - for those who do not realise it - when we count stuff the translations might be different for different numbers (1, 2, 5, 6 might all have different translations). i18n supports it - we need to just specify which "forms" each language has. We had support for it but it was a default fallback and some languages had no proper forms defined - I fixed the configuration (and made sure we have to specify forms for each language in the future) in this PR.

And after this one is merged, you should run your language with --add-missing and the missing keys should be automatically generated. You can also play with your language settings here: https://jsfiddle.net/6bpxsgd4 -> this will tell you which form is used with which number so you should be able to easily figure out the right forms.

Sorry for so late notice - but I realised it only yesterday that we probably dropped a few small balls here :)

@potiuk
potiuk force-pushed the fix-plural-forms-for-translations branch 2 times, most recently from 2e3d5fe to 3b08318 Compare September 6, 2025 15:01

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small nit, otherwise LGTM :)

@potiuk
potiuk force-pushed the fix-plural-forms-for-translations branch from 3b08318 to 55a92a1 Compare September 6, 2025 15:14
It turned out, that some of the languages we had, did not have
proper plural forms defined. There were few problems with it:

* some languages had "default" form defined where they should have
  other forms
* there were no check if language was missing in the plural forms,
  so new languages got the "default" form by - well - default.
* we had no check in CI to check if languages are defined in the
  plural forms

This PR modifies the `check-translations-completeness` script and
uses it as a prek (manual) hook to make it easier to get run, also
to be able to run it in CI - it exits with non-zero exit only when
there is a clear issue with configuration or call parameters,
rather than when there are missing translations, it only prints
green/red message summarizing the output.
@potiuk
potiuk force-pushed the fix-plural-forms-for-translations branch from 55a92a1 to 0d70277 Compare September 6, 2025 15:25
@potiuk

potiuk commented Sep 6, 2025

Copy link
Copy Markdown
Member Author

The nice thing about it is that we should see the completeness report now printed in all the PRs and canary runs in a separate CI job.

@potiuk

potiuk commented Sep 6, 2025

Copy link
Copy Markdown
Member Author

@potiuk

potiuk commented Sep 6, 2025

Copy link
Copy Markdown
Member Author

And the check-translations-completeness script itself is tested now automatically by running it in CI :)

@potiuk
potiuk merged commit eda82ca into apache:main Sep 6, 2025
@potiuk
potiuk deleted the fix-plural-forms-for-translations branch September 6, 2025 16:13
@github-actions

github-actions Bot commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

Backport failed to create: v3-0-test. View the failure log Run details

Status Branch Result
❌ v3-0-test Commit Link

You can attempt to backport this manually by running:

cherry_picker eda82ca v3-0-test

This should apply the commit to the v3-0-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

@bugraoz93

Copy link
Copy Markdown
Contributor

Will update the missing once soon. Thanks Jarek!

@jscheffl

jscheffl commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

Backport failed to create: v3-0-test. View the failure log Run details

Status Branch Result
❌ v3-0-test Commit Link

Note: should not backport.

@jscheffl

jscheffl commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

Small correction: For esit is:
@bbovenzi # + @aoelvp94

@Dev-iL

Dev-iL commented Sep 8, 2025 •

Copy link
Copy Markdown
Collaborator

In addition to the rules provided in the i18n jsfiddle, we might want to consider rules for floats. See discussion in the Factorio project as an example.

Also, it is conceivable there might be cases where translators want to add a case that's not defined in i18n for their language, e.g. _two if they want to use the equivalent of "both" for some reason.

@potiuk

potiuk commented Sep 8, 2025 •

Copy link
Copy Markdown
Member Author

In addition to the rules provided in the i18n jsfiddle, we might want to consider rules for floats. See discussion in the Factorio project as an example.

Good point, but I don't think we have floats in Airflow UI phrases. Looklng at the current phrases we have exclusively counts and strings - and it's quite unlikely we will ever have floats.

And even if we would have i18next library we use already has all the rules necessary it seems for example https://www.i18next.com/translation-function/formatting (for decimal formatiing, but also dates, time, relative time etc. ). Also for plural forms for decimal numbers, they seem to be included already - for example _other in PL is used for decimal formatting. The jsfiddle just uses ints and does not explain where _other is used (if you choose pl as language, you will see that _other is not possible to be generated), so I looked it up - actually yesterday - and in PL this is the form which will be used for "everything else" including decimals (and I belive i18next will properly choose the right forms for each language. And I saw also similar _other in other languages.

Also, it is conceivable there might be cases where translators want to add a case that's not defined in i18n for their language, e.g. _two if they want to use the equivalent of "both" for some reason.

Yep, if we get to the point i18next has the option to use custom formatters https://www.i18next.com/translation-function/formatting and we can specify which formatters we should use when it comes to it.

I actualy found i18next (it seems it's been refactored and rewritten failrly recently) as very comprehensive and helpful for all internationalisation rules.

potiuk pushed a commit to aaiss0927/airflow-1 that referenced this pull request Nov 1, 2026
The checker computed its per-file statistics inside the rich table
rendering loop, so the report existed only as terminal output. Extract
the aggregation into build_completeness_report() and add a --json flag
that prints the same data as a single JSON document on stdout —
following the breeze ci verify --json pattern (apache#73241): narration is
suppressed (or sent to stderr with --verbose) so the output can be
piped straight to jq.

The default output stays byte-identical, exit-code semantics are
unchanged (apache#55327), and the existing --language/--add-missing/
--remove-unused flags compose with --json.

closes: apache#75772

Co-Authored-By: Claude Fable 5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01A18rBgPJ6X4oXAzsecJjnz
potiuk pushed a commit that referenced this pull request Nov 1, 2026
The checker computed its per-file statistics inside the rich table
rendering loop, so the report existed only as terminal output. Extract
the aggregation into build_completeness_report() and add a --json flag
that prints the same data as a single JSON document on stdout —
following the breeze ci verify --json pattern (#73241): narration is
suppressed (or sent to stderr with --verbose) so the output can be
piped straight to jq.

The default output stays byte-identical, exit-code semantics are
unchanged (#55327), and the existing --language/--add-missing/
--remove-unused flags compose with --json.

closes: #75772

Co-Authored-By: Claude Fable 5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01A18rBgPJ6X4oXAzsecJjnz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:translations area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants