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

Pluralization not working #100

Closed
rbarkhouse opened this issue May 1, 2018 · 2 comments
Closed

Pluralization not working #100

rbarkhouse opened this issue May 1, 2018 · 2 comments

Comments

@rbarkhouse
Copy link

rbarkhouse commented May 1, 2018

I'm trying to use the Polyglot plural syntax but it doesn't seem to be working as expected... I have the following string in my bundle:

"NumberOfNetworksReporting": "%{count} network is reporting |||| %{count} networks are reporting"

If I provide an object with interpolation values, it ends up printing the whole string with both forms, including the pipe characters:

<p>{props.p.tu('NumberOfNetworksReporting', { count: 0 })}</p>
<p>{props.p.tu('NumberOfNetworksReporting', { count: 1 })}</p>
<p>{props.p.tu('NumberOfNetworksReporting', { count: 2 })}</p>

Result:
0 NETWORK IS REPORTING |||| 0 NETWORKS ARE REPORTING
1 NETWORK IS REPORTING |||| 1 NETWORKS ARE REPORTING
2 NETWORK IS REPORTING |||| 2 NETWORKS ARE REPORTING

If I use Polyglot's alternate syntax (pass a number as the second argument), it appears to be doing the proper plural phrase selection, but it doesn't substitute the actual value:

<p>{props.p.tu('NumberOfNetworksReporting', 0)}</p>
<p>{props.p.tu('NumberOfNetworksReporting', 1)}</p>
<p>{props.p.tu('NumberOfNetworksReporting', 2)}</p>

Result:
%{COUNT} NETWORKS ARE REPORTING
%{COUNT} NETWORK IS REPORTING
%{COUNT} NETWORKS ARE REPORTING

Any suggestions?
Rick

@guillaumearm
Copy link
Collaborator

Hello @rbarkhouse,

According to the polyglot.js documentation, it seems like you have to use ${smart_count} variable name to activate pluralization feature.

Anyway, I think some tests should be added about this features. (pluralization, interpolation).

@rbarkhouse
Copy link
Author

Ack, you are very right, I didn't notice that in their docs. Thanks, and thanks for this library!

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

No branches or pull requests

2 participants