Repository navigation
Give new PO files as many plural forms as --plural-forms-header says - #461
Open
oliver-kriska wants to merge 1 commit into
Open
oliver-kriska wants to merge 1 commit into
oliver-kriska wants to merge 1 commit into
Conversation
`mix gettext.merge --plural-forms-header` wrote the given Plural-Forms header to a new PO file but took the number of msgstr entries from the locale, so a three-form header for Italian came with two forms per message. Such a file logs "message is missing plural form 2" when it is compiled and raises Gettext.PluralFormError for a count that needs the third form. Gettext.Merger.new_po_file/4 now takes the number of forms from the header when Expo can parse it. An explicit :plural_forms option and a header that cannot be parsed behave as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mix gettext.merge --locale it --plural-forms-header "nplurals=3; ..."creates a PO file with the givenPlural-Formsheader, but each plural message gets the locale's default number ofmsgstr[n]entries (two for Italian).message is missing plural form 2 which is required by the locale "it"when the backend compiles, and raisesGettext.PluralFormErrorfor a count that selects the third form.Gettext.Merger.new_po_file/4now takes the number of forms from the header when Expo can parse it.For a new
itPO file with one plural message:--plural-forms-headerPlural-Formsin the filemsgstr[n]entries beforenplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;Not changed:
:plural_formsoption passed tonew_po_file/4still wins over the header.Plural-Formsheader and takes the number of forms from it, so the flag only has an effect when a file is created. I left that alone, since changing it needs a decision about existing translations.Checks
gettext.merge_test.exs, next to "...with custom plural forms": a parsable three-form header givesmsgstr[0],msgstr[1]andmsgstr[2]. It fails onmainwith two entries.new_po_file/4inmerger_test.exs: an explicit:plural_formsbeats the header, and a header that cannot be parsed keeps the locale's count. Both also pass onmain; they pin the behaviour that must not change.Gettext.PluralFormError.mix format --check-formatted,mix compile --warnings-as-errorsandmix testpass (201 passed).🤖 Generated with Claude Code