Permalink
7a7843f Oct 15, 2016
@ichernev @timrwood @rjruizes @gbrmachado
50 lines (37 sloc) 1.11 KB
title version signature
Loading locales in the browser
1.0.0
// From 2.8.1 onward moment.locale(String, Object); // Deprecated in 2.8.1 moment.lang(String, Object);

Loading locales in the browser just requires you to include the locale files.

<script src="moment.js"></script>
<script src="locale/fr.js"></script>
<script src="locale/pt.js"></script>
<script>
  moment.locale('fr');  // Set the default/global locale
  // ...
</script>

There are minified versions of all locales together:

<script src="moment.js"></script>
<script src="min/locales.js"></script>

To minimize http requests, use our Grunt task to compile Moment with a custom list of locales:

grunt transpile:fr,it
<script src="min/moment-with-locales.custom.js"></script>

If you are using JSPM as plugin manager, you should add the locale in your lib.

import * as moment from 'moment';
import 'moment/locale/fr';

Note: Locale files are defined in UMD style, so they should work seamlessly in all environments.