Repository navigation
fix(translations): accept explicit plural forms in writeTranslation - #18
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: cbb3dbd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A single string is split into plural forms heuristically, before every %d. That only works when each form starts with %d: a sentence like "This link is valid for %d hours" ends up as ["This link is valid for ", "%d hours..."]. The value can now be an array of forms, sent to Weblate as is. Plural forms in the output were joined without a separator, so a broken split looked the same as a correct one; they are now separated by " | ".
dada-amater
force-pushed
the
fix/explicit-plural-forms
branch
from
October 15, 2026 12:00
052a17f to
d960a72
Compare
dada-amater
marked this pull request as ready for review
October 15, 2026 12:00
CI installs pnpm latest, which now fails pnpm install --frozen-lockfile with ERR_PNPM_IGNORED_BUILDS for @nestjs/core. Its postinstall only prints an Open Collective banner, so it is explicitly not run.
dada-amater
force-pushed
the
fix/explicit-plural-forms
branch
from
October 15, 2026 12:06
cbb3dbd to
2835bca
Compare
Contributor
Author
|
The CI failure was not caused by this change: I added a separate commit with |
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.
Problem
For a plural unit,
writeTranslation/bulkWriteTranslationssplit the singlevaluestring into forms heuristically, before every%d. That works only when each form starts with%d. A sentence with text before the number is cut in the wrong place:There is no way to pass the forms unambiguously. The output also joins plural forms with an empty string, so a broken split looks exactly like a correct one.
Change
valueaccepts either a string (unchanged behaviour, the heuristic still applies) or an array with one string per plural form. The array is sent to Weblate as is, so Weblate validates the number of forms.|.Tested against a Weblate instance with plural units in en (2 forms), cs/pl/ru (3 forms) and es/fr/it/pt (3 forms, CLDR "many").