Closed SamiSammour closed 8 years ago
Are these locale files somehow available if you require('moment') in a node app?
Your only recourse for customizing browserify behavior is through the config.
As they say on their website Loading locales in NodeJS once you call moment.locale('fr');
the locale is loaded. but when I tried it in my ember application it's not loaded and I get the text in English not in French. My function looks like this:
import moment from 'npm:moment';
export function dateRelative(params/*, hash*/) {
var date = params[0] || new Date();
return moment(date).locale('fr').fromNow();
}
I think you should be able to solve it by importing the locale manually. Apparently it's not included in the build as it's being require
d at a late stage.
Just add
import momentFR from 'npm:moment/locale/fr';
to your app.js
file.
Just add
import momentFR from 'npm:moment/locale/fr'; to your app.js file.
^
I am using ember-browserify to work with momentjs in my ember app and I need to specify the locale for moment but I couldn't because the required locale files are not loaded. is there any way that I can tell browserify to load these files? they are located in the 'locale' folder inside moment nodes_module folder.