Can I change the locale of momentJS on the fly?

Jason Wood:
Can I change the locale of momentJS on the fly? I tried an action with require('moment/locale/fr'); but it crashes the app.


Delfs:
I don’t think all the locales are included in the base code. @Eduardo Aramizu could check when on.

If not you could add it via a dm link I’d think.


Eduardo Aramizu:
correct, we don’t have locales included. Got it working with CDN

<script src="<https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/fr.min.js>" integrity="sha512-RAt2+PIRwJiyjWpzvvhKAG2LEdPpQhTgWfbEkFDCo8wC4rFYh5GQzJBVIFDswwaEDEYX16GEE/4fpeDNr7OIZw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

and sample code

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

source: https://momentjscom.readthedocs.io/en/latest/moment/06-i18n/02-instance-locale/