Skip to content

problem with plurals string #275

Description

@padmarao123

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

Activity

  1. rubenv commented on Mar 25, 2016

    @rubenv
    Owner

    Can you make a jsFiddle example?

  2. padmarao123 commented on Apr 7, 2016

    @padmarao123
    Author
    One boat

    this not working

  3. rubenv commented on Apr 7, 2016

    @rubenv
    Owner

    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.

  4. padmarao123 commented on Apr 12, 2016

    @padmarao123
    Author

    slove my problem my self
    thank u so much ur contribution

  5. agrajaghh commented on Oct 18, 2016

    @agrajaghh

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

  6. rubenv commented on Oct 19, 2016

    @rubenv
    Owner

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

  7. agrajaghh commented on Oct 19, 2016

    @agrajaghh

    @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?

  8. agrajaghh commented on Oct 19, 2016

    @agrajaghh

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

  9. rubenv commented on Oct 19, 2016

    @rubenv
    Owner

    @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.

  10. agrajaghh commented on Oct 19, 2016

    @agrajaghh

    @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

  11. rubenv commented on Oct 19, 2016

    @rubenv
    Owner

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

  12. agrajaghh commented on Oct 19, 2016

    @agrajaghh

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

    #320

  13. zhuangya commented on Oct 20, 2016

    @zhuangya

    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.....

  14. ngehlert commented on May 2, 2017

    @ngehlert

    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

  15. rubenv commented on May 2, 2017

    @rubenv
    Owner

    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.

  16. ngehlert commented on May 2, 2017

    @ngehlert

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions