Skip to content

Commit ad53e9b

Browse files
committed
feat: localize week day names
- get week day names from dayjs locale - add locale name to `day-of-week` slot data
1 parent aa1763c commit ad53e9b

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

src/components/core/calendar.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
>
4040
<template
4141
slot="day-of-week"
42-
slot-scope="{wd, index}">
42+
slot-scope="{ name, index, locale }">
4343
<slot
44-
v-bind="{wd, index}"
44+
v-bind="{ name, index, locale }"
4545
name="day-of-week">
46-
{{ wd }}
46+
{{ name }}
4747
</slot>
4848

4949
</template>

src/components/core/month.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
</div>
88
<div class="vuec-week-nav vuec-7col">
99
<div
10-
v-for="(wd, index) in weekDays"
10+
v-for="(name, index) in weekDays"
1111
:key="index"
1212
class="vuec-col">
1313
<div class="vuec-week-content">
1414
<slot
15-
v-bind="{wd, index}"
15+
v-bind="{ name, index, locale }"
1616
name="day-of-week">
17-
{{ wd }}
17+
{{ name }}
1818
</slot>
1919
</div>
2020
<div class="vuec-week-placeholder"/>
@@ -59,7 +59,6 @@
5959
import dayjs from '../../date';
6060
6161
import DayView from './day.vue';
62-
import { weekDays } from '../../utils';
6362
6463
export default {
6564
components: {
@@ -101,7 +100,8 @@ export default {
101100
},
102101
data() {
103102
return {
104-
weekDays: weekDays(),
103+
locale: this.date.$locale().name,
104+
weekDays: this.date.$locale().weekdays,
105105
};
106106
},
107107
computed: {

src/utils.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,3 @@ export function toEnglishDigits(value) {
4141
.replace(/[۰-۹]/g, w => w.charCodeAt(0) - PERSIAN_ZERO_CHAR_CODE)
4242
.replace(/[٠-٩]/g, w => w.charCodeAt(0) - ARABIC_ZERO_CHAR_CODE);
4343
}
44-
45-
export function weekDays() {
46-
return [
47-
'شنبه',
48-
'۱ شنبه',
49-
'۲ شنبه',
50-
'۳ شنبه',
51-
'۴ شنبه',
52-
'۵ شنبه',
53-
'جمعه',
54-
];
55-
}

0 commit comments

Comments
 (0)