Repository navigation
problem with plurals string #275
Description
Activity
Can you make a jsFiddle example?
- One boat
this not working
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.
slove my problem my self
thank u so much ur contribution@rubenv can you please reopen this issue? I have the same problem:
https://jsfiddle.net/2cfu59c3/@agrajaghh why are you assigning a string to something that is supposed to be a number?
@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?oh, I saw there is already a PR for it: #315
@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.
@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
Sure, let's make it throw an error if the
nparameter is not a number.Sure, let's make it throw an error if the n parameter is not a number.
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.....
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 translationsSometimes 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
twomeans you won't get the correct plural form. This should definitely be an error.@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
i am using translate-n for plurals string as shown below
original(problem ) output:Your Priority available only 1%. every time get message like that