moment-2.8 compatibility, language file generation

This commit is contained in:
Adam Shaw
2014-08-06 16:57:15 -07:00
parent 48f4a33671
commit e92c85d1e1
2 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -123,7 +123,7 @@ module.exports = function(grunt) {
]);
config.generateLanguages = {
moment: 'lib/moment/lang/',
moment: grunt.file.expand('lib/moment/{locale,lang}/')[0], // lang directory is pre-moment-2.8
datepicker: 'lib/jquery-ui/ui/i18n/',
fullCalendar: 'lang/',
dest: 'build/temp/lang/',
+6 -4
View File
@@ -36,7 +36,7 @@ module.exports = function(grunt) {
});
// code for resetting the language back to English
combinedJS += '\nmoment.lang("en");';
combinedJS += '\n(moment.locale || moment.lang).call(moment, "en");'; // works with moment-pre-2.8
combinedJS += '\n$.fullCalendar.lang("en");';
combinedJS += '\nif ($.datepicker) $.datepicker.setDefaults($.datepicker.regional[""]);';
@@ -133,9 +133,11 @@ module.exports = function(grunt) {
}
);
js = js.replace( // replace the `return` statement so execution continues
/^(\s*)return moment\.lang\(/m,
'$1moment.lang('
// replace the `return` statement so execution continues
// compatible with moment-pre-2.8
js = js.replace(
/^(\s*)return moment\.(defineLocale|lang)\(/m,
'$1(moment.defineLocale || moment.lang).call(moment, '
);
return js;