locale.js (946B)
1import { getLocale } from '../locale/locales'; 2import { deprecate } from '../utils/deprecate'; 3 4// If passed a locale key, it will set the locale for this 5// instance. Otherwise, it will return the locale configuration 6// variables for this instance. 7export function locale(key) { 8 var newLocaleData; 9 10 if (key === undefined) { 11 return this._locale._abbr; 12 } else { 13 newLocaleData = getLocale(key); 14 if (newLocaleData != null) { 15 this._locale = newLocaleData; 16 } 17 return this; 18 } 19} 20 21export var lang = deprecate( 22 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', 23 function (key) { 24 if (key === undefined) { 25 return this.localeData(); 26 } else { 27 return this.locale(key); 28 } 29 } 30); 31 32export function localeData() { 33 return this._locale; 34}