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

Literal 1 in plural choice string causes wrong string to be selected #631

Closed
jjfmarket opened this issue Jan 27, 2021 · 1 comment
Closed

Comments

@jjfmarket
Copy link

jjfmarket commented Jan 27, 2021

I have a plural choice translate string in my twig template:
{{ '{0} Coming soon |{1} 1 Open Position|[2,Inf[ :count Open positions'|__(hiring.job_count, {count: hiring.job_count}) }}

When hiring.job_count is 1, the selected string will be "Coming Soon", instead of the expected "1 Open Position"
Replacing the literal 1 in the singular string causes the proper string to be selected, these two examples both work as expected:

{{ '{0} Coming soon |{1} :count Open Position|[2,Inf[ :count Open positions'|__(hiring.job_count, {count: hiring.job_count}) }}
{{ '{0} Coming soon |{1} One Open Position|[2,Inf[ :count Open positions'|__(hiring.job_count, {count: hiring.job_count}) }}

Note that when using laravels transchoice filter, this issue does not occur
{{ '{0} Coming soon |{1} 1 Open Position|[2,Inf[ :count Open positions'|transchoice(hiring.job_count) }}

@daftspunk
Copy link
Member

It appears that there may be an error in the code you have written.

{0} Coming soon |{1} 1 Open Position|[2,Inf[ :count Open positions

The code should be.

{0} Coming soon |{1} 1 Open Position|[2,Inf] :count Open positions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants