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

problem with plurals string #275

Closed
padmarao123 opened this issue Mar 25, 2016 · 16 comments
Closed

problem with plurals string #275

padmarao123 opened this issue Mar 25, 2016 · 16 comments
Labels

Comments

@padmarao123
Copy link

i am using translate-n for plurals string as shown below

Your Priority available only 1%.
total variable value is 40 excepted output :Your priority available 40 %.

original(problem ) output:Your Priority available only 1%. every time get message like that

@rubenv
Copy link
Owner

rubenv commented Mar 25, 2016

Can you make a jsFiddle example?

@padmarao123
Copy link
Author

One boat

this not working

@rubenv
Copy link
Owner

rubenv commented Apr 7, 2016

What I meant is, please make an example that reproduces your bug here: https://jsfiddle.net/

I cannot help you sort this out without seeing what exactly you are doing.

@padmarao123
Copy link
Author

slove my problem my self
thank u so much ur contribution

@agrajaghh
Copy link

@rubenv can you please reopen this issue? I have the same problem:
https://jsfiddle.net/2cfu59c3/

@rubenv
Copy link
Owner

rubenv commented Oct 19, 2016

@agrajaghh why are you assigning a string to something that is supposed to be a number?

@agrajaghh
Copy link

@rubenv we have some metadata stored in a db table as strings (strings, dates, ints) and pass them via a REST API to angular. I know thats probably not the best way...

Would you accept a PR which uses parseFloat() to determine if its singular or plural?

@agrajaghh
Copy link

oh, I saw there is already a PR for it: #315

@rubenv
Copy link
Owner

rubenv commented Oct 19, 2016

@agrajaghh Make sure your data is correct at the source.

Sending in a bad data type usually indicates a bug. Casting it on our side will only mask those.

@agrajaghh
Copy link

agrajaghh commented Oct 19, 2016

@rubenv I don't think silently always falling back to plural is the better alternative. It should then fail at all and produce no string or something like that if the argument is a string

@rubenv
Copy link
Owner

rubenv commented Oct 19, 2016

Sure, let's make it throw an error if the n parameter is not a number.

@agrajaghh
Copy link

Sure, let's make it throw an error if the n parameter is not a number.

#320

@zhuangya
Copy link

Sure, let's make it throw an error if the n parameter is not a number.

for god's sake, why not just convert it.....

@ngehlert
Copy link

ngehlert commented May 2, 2017

Sure, let's make it throw an error if the n parameter is not a number.

@rubenv @agrajaghh
Please don't.... This does not make any sense. Why force a number there? If you really need it check it before you call the getPlural function.
Sometimes you might want to use the written number instead of the value e.g. "two days remaining" instead of "2 days remaining".
Also if you throw an error if it is not a number you can no longer use other string params in plural translations

@rubenv
Copy link
Owner

rubenv commented May 2, 2017

Sometimes you might want to use the written number instead of the value e.g. "two days remaining" instead of "2 days remaining".

@ngehlert That is wrong in every way... Passing two means you won't get the correct plural form. This should definitely be an error.

@ngehlert
Copy link

ngehlert commented May 2, 2017

@rubenv the plural form is determined by the first function parameter, not by the parameter itself isn't it?
gettextCatalog.getPlural(n, string, stringPlural, context)

example:
gettextCatalog.getPlural(2, "MY_KEY_WITH_NUMBER {{param}}", "MY_KEY_WITH_NUMBER_PLURAL {{param}}", {param: 'anything'})

edit: oh nvm I misread the comment and thought you were talking about the last parameter and not the first one. I had a completely different use case in mind sorry :D

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

No branches or pull requests

5 participants