Skip to content

Commit

Permalink
Merge pull request #525 from t-tomek/master
Browse files Browse the repository at this point in the history
chore: rename t() to transtlateFn()
  • Loading branch information
mengxiong10 authored Oct 17, 2020
2 parents b0ff9d2 + 27b21b9 commit ddab99c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/calendar/calendar-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default {
},
mixins: [emitter],
inject: {
t: {
translateFn: {
default: () => getLocaleFieldValue,
},
prefixClass: {
Expand Down Expand Up @@ -207,9 +207,9 @@ export default {
return this.panel === 'date';
},
dateHeader() {
const monthBeforeYear = this.t('monthBeforeYear');
const yearFormat = this.t('yearFormat');
const monthFormat = this.t('monthFormat') || 'MMM';
const monthBeforeYear = this.translateFn('monthBeforeYear');
const yearFormat = this.translateFn('yearFormat');
const monthFormat = this.translateFn('monthFormat') || 'MMM';
const yearLabel = {
panel: 'year',
label: this.formatDate(this.innerCalendar, yearFormat),
Expand All @@ -235,7 +235,7 @@ export default {
},
methods: {
formatDate(date, fmt) {
return format(date, fmt, { locale: this.t('formatLocale') });
return format(date, fmt, { locale: this.translateFn('formatLocale') });
},
initCalendar() {
let calendarDate = this.calendar;
Expand Down
10 changes: 5 additions & 5 deletions src/calendar/table-date.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { getLocaleFieldValue } from '../locale';
export default {
name: 'TableDate',
inject: {
t: {
translateFn: {
default: () => getLocaleFieldValue,
},
getWeek: {
Expand Down Expand Up @@ -85,10 +85,10 @@ export default {
},
computed: {
firstDayOfWeek() {
return this.t('formatLocale.firstDayOfWeek') || 0;
return this.translateFn('formatLocale.firstDayOfWeek') || 0;
},
days() {
const days = this.t('days') || this.t('formatLocale.weekdaysMin');
const days = this.translateFn('days') || this.translateFn('formatLocale.weekdaysMin');
return days.concat(days).slice(this.firstDayOfWeek, this.firstDayOfWeek + 7);
},
dates() {
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
},
methods: {
formatDate(date, fmt) {
return format(date, fmt, { locale: this.t('formatLocale') });
return format(date, fmt, { locale: this.translateFn('formatLocale') });
},
handleCellClick(evt) {
let { target } = evt;
Expand All @@ -148,7 +148,7 @@ export default {
const year = this.calendarYear;
const month = this.calendarMonth;
const date = createDate(year, month, day);
return this.getWeek(date, this.t('formatLocale'));
return this.getWeek(date, this.translateFn('formatLocale'));
},
},
};
Expand Down
5 changes: 3 additions & 2 deletions src/calendar/table-month.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { getLocaleFieldValue } from '../locale';
export default {
name: 'TableMonth',
inject: {
t: {
translateFn: {
default: () => getLocaleFieldValue,
},
prefixClass: {
Expand All @@ -38,7 +38,8 @@ export default {
},
computed: {
months() {
const monthsLocale = this.t('months') || this.t('formatLocale.monthsShort');
const monthsLocale =
this.translateFn('months') || this.translateFn('formatLocale.monthsShort');
const months = monthsLocale.map((text, month) => {
return { text, month };
});
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default {
},
provide() {
return {
t: this.getLocaleFieldValue,
translateFn: this.getLocaleFieldValue,
getWeek: this.getWeek,
prefixClass: this.prefixClass,
};
Expand Down
4 changes: 2 additions & 2 deletions src/time/list-options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default {
name: 'ListOptions',
components: { ScrollbarVertical },
inject: {
t: {
translateFn: {
default: () => getLocaleFieldValue,
},
prefixClass: {
Expand Down Expand Up @@ -99,7 +99,7 @@ export default {
},
methods: {
formatDate(date, fmt) {
return format(date, fmt, { locale: this.t('formatLocale') });
return format(date, fmt, { locale: this.translateFn('formatLocale') });
},
scrollToSelected() {
const element = this.$el.querySelector('.active');
Expand Down
4 changes: 2 additions & 2 deletions src/time/time-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
name: 'TimePanel',
components: { ListColumns, ListOptions },
inject: {
t: {
translateFn: {
default: () => getLocaleFieldValue,
},
prefixClass: {
Expand Down Expand Up @@ -149,7 +149,7 @@ export default {
},
methods: {
formatDate(date, fmt) {
return format(date, fmt, { locale: this.t('formatLocale') });
return format(date, fmt, { locale: this.translateFn('formatLocale') });
},
isDisabled(date) {
return this.disabledTime(new Date(date));
Expand Down

0 comments on commit ddab99c

Please sign in to comment.