Skip to content

Commit ddab99c

Browse files
authored
Merge pull request #525 from t-tomek/master
chore: rename t() to transtlateFn()
2 parents b0ff9d2 + 27b21b9 commit ddab99c

6 files changed

+18
-17
lines changed

src/calendar/calendar-panel.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default {
125125
},
126126
mixins: [emitter],
127127
inject: {
128-
t: {
128+
translateFn: {
129129
default: () => getLocaleFieldValue,
130130
},
131131
prefixClass: {
@@ -207,9 +207,9 @@ export default {
207207
return this.panel === 'date';
208208
},
209209
dateHeader() {
210-
const monthBeforeYear = this.t('monthBeforeYear');
211-
const yearFormat = this.t('yearFormat');
212-
const monthFormat = this.t('monthFormat') || 'MMM';
210+
const monthBeforeYear = this.translateFn('monthBeforeYear');
211+
const yearFormat = this.translateFn('yearFormat');
212+
const monthFormat = this.translateFn('monthFormat') || 'MMM';
213213
const yearLabel = {
214214
panel: 'year',
215215
label: this.formatDate(this.innerCalendar, yearFormat),
@@ -235,7 +235,7 @@ export default {
235235
},
236236
methods: {
237237
formatDate(date, fmt) {
238-
return format(date, fmt, { locale: this.t('formatLocale') });
238+
return format(date, fmt, { locale: this.translateFn('formatLocale') });
239239
},
240240
initCalendar() {
241241
let calendarDate = this.calendar;

src/calendar/table-date.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { getLocaleFieldValue } from '../locale';
3939
export default {
4040
name: 'TableDate',
4141
inject: {
42-
t: {
42+
translateFn: {
4343
default: () => getLocaleFieldValue,
4444
},
4545
getWeek: {
@@ -85,10 +85,10 @@ export default {
8585
},
8686
computed: {
8787
firstDayOfWeek() {
88-
return this.t('formatLocale.firstDayOfWeek') || 0;
88+
return this.translateFn('formatLocale.firstDayOfWeek') || 0;
8989
},
9090
days() {
91-
const days = this.t('days') || this.t('formatLocale.weekdaysMin');
91+
const days = this.translateFn('days') || this.translateFn('formatLocale.weekdaysMin');
9292
return days.concat(days).slice(this.firstDayOfWeek, this.firstDayOfWeek + 7);
9393
},
9494
dates() {
@@ -125,7 +125,7 @@ export default {
125125
},
126126
methods: {
127127
formatDate(date, fmt) {
128-
return format(date, fmt, { locale: this.t('formatLocale') });
128+
return format(date, fmt, { locale: this.translateFn('formatLocale') });
129129
},
130130
handleCellClick(evt) {
131131
let { target } = evt;
@@ -148,7 +148,7 @@ export default {
148148
const year = this.calendarYear;
149149
const month = this.calendarMonth;
150150
const date = createDate(year, month, day);
151-
return this.getWeek(date, this.t('formatLocale'));
151+
return this.getWeek(date, this.translateFn('formatLocale'));
152152
},
153153
},
154154
};

src/calendar/table-month.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { getLocaleFieldValue } from '../locale';
2121
export default {
2222
name: 'TableMonth',
2323
inject: {
24-
t: {
24+
translateFn: {
2525
default: () => getLocaleFieldValue,
2626
},
2727
prefixClass: {
@@ -38,7 +38,8 @@ export default {
3838
},
3939
computed: {
4040
months() {
41-
const monthsLocale = this.t('months') || this.t('formatLocale.monthsShort');
41+
const monthsLocale =
42+
this.translateFn('months') || this.translateFn('formatLocale.monthsShort');
4243
const months = monthsLocale.map((text, month) => {
4344
return { text, month };
4445
});

src/date-picker.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export default {
151151
},
152152
provide() {
153153
return {
154-
t: this.getLocaleFieldValue,
154+
translateFn: this.getLocaleFieldValue,
155155
getWeek: this.getWeek,
156156
prefixClass: this.prefixClass,
157157
};

src/time/list-options.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default {
4040
name: 'ListOptions',
4141
components: { ScrollbarVertical },
4242
inject: {
43-
t: {
43+
translateFn: {
4444
default: () => getLocaleFieldValue,
4545
},
4646
prefixClass: {
@@ -99,7 +99,7 @@ export default {
9999
},
100100
methods: {
101101
formatDate(date, fmt) {
102-
return format(date, fmt, { locale: this.t('formatLocale') });
102+
return format(date, fmt, { locale: this.translateFn('formatLocale') });
103103
},
104104
scrollToSelected() {
105105
const element = this.$el.querySelector('.active');

src/time/time-panel.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
name: 'TimePanel',
4848
components: { ListColumns, ListOptions },
4949
inject: {
50-
t: {
50+
translateFn: {
5151
default: () => getLocaleFieldValue,
5252
},
5353
prefixClass: {
@@ -149,7 +149,7 @@ export default {
149149
},
150150
methods: {
151151
formatDate(date, fmt) {
152-
return format(date, fmt, { locale: this.t('formatLocale') });
152+
return format(date, fmt, { locale: this.translateFn('formatLocale') });
153153
},
154154
isDisabled(date) {
155155
return this.disabledTime(new Date(date));

0 commit comments

Comments
 (0)