adamwdraper / Numeral-js

A javascript library for formatting and manipulating numbers.
http://numeraljs.com
MIT License
9.66k stars 928 forks source link

twice locale Registration issue #503

Open kinguru opened 7 years ago

kinguru commented 7 years ago

Hi,

Why second Locale registration throws an excpetion? My scenarion: I need dynamically update Locale by ajax. How I can do it in current codebase?

Thank you.

fluse commented 7 years ago

i have the same problem, please remove following line:

https://github.com/adamwdraper/Numeral-js/blob/master/src/numeral.js#L468

acarl commented 7 years ago

I agree that this is an issue. In the mean time I worked around it by just checking to see if it exists first.

if (numeral.locales['user-locale'] === undefined) {
  numeral.register('locale', 'user-locale', {});
}
RaulTsc commented 6 years ago

......... this is really not fixed yet? Why would anyone want to throw? Just overwrite it.

Softie42 commented 6 years ago

The workaround above works for me in react. Thanks.

jeancabral commented 5 years ago

The workaround works for me too

ZaidQ797 commented 3 years ago

I agree that this is an issue. In the mean time I worked around it by just checking to see if it exists first.

if (numeral.locales['user-locale'] === undefined) {
  numeral.register('locale', 'user-locale', {});
}

thanks, buddy it worked!!!