Commit 22aae949 authored by Leopoldthecoder's avatar Leopoldthecoder Committed by 杨奕

DatePicker: fix fecha i18n not responsive

parent d31b33a1
...@@ -3,12 +3,13 @@ import { t } from 'element-ui/src/locale'; ...@@ -3,12 +3,13 @@ import { t } from 'element-ui/src/locale';
const weeks = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; const weeks = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
const months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; const months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
const getI18nSettings = () => {
dateUtil.i18n = { return {
dayNamesShort: weeks.map(week => t(`el.datepicker.weeks.${ week }`)), dayNamesShort: weeks.map(week => t(`el.datepicker.weeks.${ week }`)),
dayNames: weeks.map(week => t(`el.datepicker.weeks.${ week }`)), dayNames: weeks.map(week => t(`el.datepicker.weeks.${ week }`)),
monthNamesShort: months.map(month => t(`el.datepicker.months.${ month }`)), monthNamesShort: months.map(month => t(`el.datepicker.months.${ month }`)),
monthNames: months.map((month, index) => t(`el.datepicker.month${ index + 1 }`)) monthNames: months.map((month, index) => t(`el.datepicker.month${ index + 1 }`))
};
}; };
const newArray = function(start, end) { const newArray = function(start, end) {
...@@ -36,11 +37,11 @@ export const isDate = function(date) { ...@@ -36,11 +37,11 @@ export const isDate = function(date) {
export const formatDate = function(date, format) { export const formatDate = function(date, format) {
date = toDate(date); date = toDate(date);
if (!date) return ''; if (!date) return '';
return dateUtil.format(date, format || 'yyyy-MM-dd'); return dateUtil.format(date, format || 'yyyy-MM-dd', getI18nSettings());
}; };
export const parseDate = function(string, format) { export const parseDate = function(string, format) {
return dateUtil.parse(string, format || 'yyyy-MM-dd'); return dateUtil.parse(string, format || 'yyyy-MM-dd', getI18nSettings());
}; };
export const getDayCountOfMonth = function(year, month) { export const getDayCountOfMonth = function(year, month) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment