Locale detection with Moment.js

As of momentjs documentation:

By default, Moment.js comes with English locale strings. If you need
other locales, you can load them into Moment.js for later use.

You can change it with that:

moment.locale(locale);

To get the user’s locale with javascript you can do that:

var locale = window.navigator.userLanguage || window.navigator.language;

Refer to: http://momentjs.com/docs/#/i18n/changing-locale/

and JavaScript for detecting browser language preference

Leave a Comment