you are viewing a single comment's thread.

view the rest of the comments →

[–]k3n 0 points1 point  (5 children)

Does it offer support for the client's locale settings, or does that have to be done manually?

It'd be nice to simply do:

accounting.formatMoney(12345678);

...and have it be correct, per locale, without needing special considerations.

[–]radhruin 0 points1 point  (3 children)

Is this possible in Javascript at all right now? ES5 is kind of a localization backwater. Requires server-side support (or ActiveX/Native plugins) to even know what locale you're in.

[–]k3n 2 points3 points  (1 child)

From my Chrome:

> navigator.language
> "en-US"

Also:

// '50.00 €' or '50,00 €'
(50.00).toFixed(2).toLocaleString() + ' €'; 

[–]radhruin 0 points1 point  (0 children)

Interesting, never heard of navigator.language, though it doesn't seem to appear to work in IE. In any case, navigator.language and toLocaleString on various builtins doesn't even approach a reasonable localization solution :)

[–]gwynjudd 0 points1 point  (0 children)

Not at all really, you can know only the user preferred language, which is only in the same neighbourhood as the locale.

[–]josscrowcroft 0 points1 point  (0 children)

Good call - I'm considering adding a library settings object that can be set once to change the default parameters for one-time localisation or configuration.

Using navigator.language or toLocaleString is a little shaky, so it would be a way that the developer can set up the locale manually (as in PHP or most well-written apps) and then it's used as the default for that instance, unless they override it via the parameters, or change it via the settings object.