Implement locale inheritance and locale updating #2774

wants to merge 1 commit into


None yet

4 participants


Users have requested this in one way or another.

Locale inheritance

Now, you can write

moment.defineLocale('en-foo', {
  parentLocale: 'en',
  /* */

which would create a new locale en-foo, taking as base the en locale and modifying the specified properties. Providing an object field (like calendar) will update only the supplied fields, the rest will be inherited. (for exampe specifying calendar: {sameDay: '...'}, will update sameDay, but keep nextDay and the other calendar attributes).

Locale update

moment.updateLocale('en', {

This has similar semantics to inheritance, but changes the specified locale, instead of creating a new one. Actually the original locale is not changed but a new one with the same name created. This means existing moments using the updated locale won't change behavior.


moment.updateLocale('en', null);

To revert an update. If there are no applied updates this removes the locale.


  • make a proper base English locale, make other locales inherit from it behind the scenes
ichernev commented Dec 9, 2015

@icambron @mj1856 any comments on this?

icambron commented Dec 9, 2015

Looks good to me.

@rafeememon rafeememon referenced this pull request in Hacker0x01/react-datepicker Dec 17, 2015

Updated proposal: Use moment defaults and preserve global settings. #257

@ichernev ichernev added this to the 2.12.0 milestone Mar 6, 2016
ichernev commented Mar 6, 2016

Merged in 78bfe90

@ichernev ichernev closed this Mar 6, 2016

when I m using moment.js in my simple html page getting "Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale " how can I fixed it ..?


@Aditya28268 if you are updating an existing locale, just use .updateLocale instead of .locale


Hello ,

I'm not using ".locale" in my code or not updating any existing locale .
I'm just trying to include your moment.js library. But then the
deprecation warning occurs.
How can I remove this warning. Or it is a library issue?
Please suggest.

On Thursday 23 June 2016 10:42 PM, Maggie Pint wrote:

@Aditya28268 if you are updating an
existing locale, just use .updateLocale instead of .locale

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2774 (comment),
or mute the thread

Warm Regards,

Aditya Singh Tomar


Hi Aditya, two quick things: 1. please don't post issues at the bottom of other issues; it creates a hassle for us and makes it harder for people who care about the issue here to find out what they want. 2. You might have better luck posting on SO or chatting with us on Gitter. The warning you're seeing isn't something that we expect to see, so it's not really possible for us to help without knowing more about what you've done, and getting to the bottom of it in Github tickets is a painful way to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment