Numeral-js icon indicating copy to clipboard operation
Numeral-js copied to clipboard

Set locale on single instance

Open heruan opened this issue 7 years ago • 7 comments

Seems like the locale can only be set globally, e.g. numeral.locale('it'). This may cause problems with async callbacks causing them to pick the wrong locale, if multiple locales are involved.

It should be possibile to set the locale for a single instance, e.g.

numeral(3.14).locale('it').format('0,00.00');

heruan avatar Oct 30 '17 13:10 heruan

I agree!!

francisrod01 avatar Nov 26 '17 18:11 francisrod01

That, as well as other global settings like zeroFormat, defaultFormat, etc.

RKushnir avatar Mar 08 '18 14:03 RKushnir

@adamwdraper any feedback on this?

heruan avatar Mar 08 '18 17:03 heruan

I guess this lib is only suitable for front end. Can't find a way to have multiple instances of numeral in node. Any clue?

libasoles avatar Oct 10 '18 20:10 libasoles

I'm also hitting this issue on an api server. I'd like to just set locale() specifically for each request and not have it globally affect all other requests.

phaddius avatar Aug 20 '19 18:08 phaddius

This is also a blocker in front end... I have data coming from different inputs for the same user and I need to parse those numbers using different locales and render them with the same format.

bejito avatar Jan 21 '20 11:01 bejito

Has anyone found another library for this issue? I'm using it in the backend and need to use a fixed locale per request.

Noitidart avatar Feb 05 '22 15:02 Noitidart