Skip to content

Conversation

kylekatarnls
Copy link
Contributor

@kylekatarnls kylekatarnls commented Aug 2, 2025

Using {1}singular|]1,Inf[plural syntax does not include 0, negative number, nor decimal numbers between 0 and 1 (like 0.5), leading Symfony to throw an exception "Unable to choose..." if such number is tried on such translation string.

For many languages, the plural form would be acceptable for 0 and negative numbers, so it would be more resilient to use the syntax {1}singular|[-Inf,Inf]plural which means to use "singular" for 1 and "plural" for anything else.

Contributors can still submit better translations for specific languages as long as we keep a fallback form (with no selector), example:

']-Inf,-1[negative plural|{-1}minus one|{0}zero|{1}one|[-Inf,Inf]other'

The part about negative is only if those files get used independently, in the default context (using Symfony Translator) getPluralizationRule contains $number = abs($number);

Fix #53

@kylekatarnls kylekatarnls added this to the 3.10.2 milestone Aug 2, 2025
@kylekatarnls kylekatarnls added the translation Rely to internationalization label Aug 2, 2025
@kylekatarnls kylekatarnls marked this pull request as draft August 2, 2025 08:18
@kylekatarnls kylekatarnls force-pushed the fix/issue-53-unable-to-choose-error branch from ec1d0b8 to fb77391 Compare August 2, 2025 08:22
@kylekatarnls kylekatarnls changed the title Remove ]1,Inf[ and simply use last part as the fallback Replace ]1,Inf[ with [-Inf,Inf] generic catch-all (fallback) Aug 2, 2025
@kylekatarnls kylekatarnls force-pushed the fix/issue-53-unable-to-choose-error branch from fb77391 to 80550fb Compare August 2, 2025 09:14
@kylekatarnls kylekatarnls force-pushed the fix/issue-53-unable-to-choose-error branch from 80550fb to 8be82a2 Compare August 2, 2025 09:29
@kylekatarnls kylekatarnls marked this pull request as ready for review August 2, 2025 09:35
@kylekatarnls kylekatarnls merged commit 76b5c07 into master Aug 2, 2025
56 checks passed
@kylekatarnls kylekatarnls deleted the fix/issue-53-unable-to-choose-error branch August 2, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
translation Rely to internationalization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing translation for locale bo_IN
1 participant