Numeral-js: twice locale Registration issue

Created on 25 Apr 2017  路  6Comments  路  Source: adamwdraper/Numeral-js

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.

Most helpful comment

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', {});
}

All 6 comments

i have the same problem, please remove following line:

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

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', {});
}

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

The workaround above works for me in react. Thanks.

The workaround works for me too

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anselms picture anselms  路  4Comments

leosco picture leosco  路  5Comments

Eric24 picture Eric24  路  8Comments

rogerfar picture rogerfar  路  8Comments

jfstephe picture jfstephe  路  4Comments