<commit_before>---
title: Changing locales locally
version: 1.7.0
signature: |
  // From version 2.8.1 onward
  moment().locale(String);

  // Deprecated version 2.8.1
  moment().lang(String);
---


A global locale configuration can be problematic when passing around moments that may need to be formatted into different locale.

In **1.7.0** we added instance specific locale configurations.

```javascript
moment.locale('en'); // default the locale to English
var globalLocale = moment();
var localLocale = moment();

localLocale.locale('fr'); // set this instance to use French
localLocale.format('LLLL'); // dimanche 15 juillet 2012 11:01
globalLocale.format('LLLL'); // Sunday, July 15 2012 11:01 AM

moment.locale('es'); // change the global locale to Spanish
localLocale.format('LLLL'); // dimanche 15 juillet 2012 11:01
globalLocale.format('LLLL'); // Domingo 15 Julio 2012 11:03

localLocale.locale(false); // reset the instance locale
localLocale.format('LLLL'); // Domingo 15 Julio 2012 11:03
globalLocale.format('LLLL'); // Domingo 15 Julio 2012 11:03
```

If you call `moment#locale` with no parameters, you get back the locale configuration that would be used for that moment.

```javascript
var fr = moment().locale('fr');
fr.locale().months(moment([2012, 0])) // "janvier"
fr.locale('en');
fr.locale().months(moment([2012, 0])) // "January"
```

If you need to access the locale data for a moment, this is the preferred way to do so.

As of **2.3.0**, you can also specify an array of locale identifiers. It works the same was it does in the [global locale configuration](http://localhost:8000/docs/#/i18n/changing-locale/).
<commit_msg>Removed localhost from global locale configuration link<commit_after>---
title: Changing locales locally
version: 1.7.0
signature: |
  // From version 2.8.1 onward
  moment().locale(String);

  // Deprecated version 2.8.1
  moment().lang(String);
---


A global locale configuration can be problematic when passing around moments that may need to be formatted into different locale.

In **1.7.0** we added instance specific locale configurations.

```javascript
moment.locale('en'); // default the locale to English
var globalLocale = moment();
var localLocale = moment();

localLocale.locale('fr'); // set this instance to use French
localLocale.format('LLLL'); // dimanche 15 juillet 2012 11:01
globalLocale.format('LLLL'); // Sunday, July 15 2012 11:01 AM

moment.locale('es'); // change the global locale to Spanish
localLocale.format('LLLL'); // dimanche 15 juillet 2012 11:01
globalLocale.format('LLLL'); // Domingo 15 Julio 2012 11:03

localLocale.locale(false); // reset the instance locale
localLocale.format('LLLL'); // Domingo 15 Julio 2012 11:03
globalLocale.format('LLLL'); // Domingo 15 Julio 2012 11:03
```

If you call `moment#locale` with no parameters, you get back the locale configuration that would be used for that moment.

```javascript
var fr = moment().locale('fr');
fr.locale().months(moment([2012, 0])) // "janvier"
fr.locale('en');
fr.locale().months(moment([2012, 0])) // "January"
```

If you need to access the locale data for a moment, this is the preferred way to do so.

As of **2.3.0**, you can also specify an array of locale identifiers. It works the same was it does in the [global locale configuration](#/i18n/changing-locale/).

{'fraction_non_alphanumeric': 0.13309244203553147, 'fraction_numerical': 0.05359831376091539, 'mean_word_length': 4.419249592169657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7647281', 'n_tokens_mistral': 1087, 'n_tokens_neox': 925, 'n_words': 382}