Skip to content

Number formatting #229

@wetneb

Description

@wetneb

I would find it nice if there was a way to format numbers according to the locale.
For instance, the number 1234.56 (as written in Javascript) should be rendered as 1,234.56 in English and 1 234,56 in French.

So it would be amazing if $.i18n('number-of-results', 1234.56) could render as There are 1,234.56 results in English and Il y a 1 234,56 résultats in French.

Apologies if this is already supported somehow, I couldn't figure it out looking at the readme.

The standard function Number.prototype.toLocaleString can of course be used but this has two downsides:

  • this will format the number according to the browser's locale, which might not be the same as the one used by this library
  • this means supplying this number as a string to jquery.i18n, so we probably break plural support by doing that (I haven't actually tried)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions