+14
-17
lines changedFilter options
+14
-17
lines changed Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
18
18
atClick: () => {
19
19
const date = new Date();
20
20
return [
21
-
new Date(date.setDate(date.getDate() - 14)),
21
+
new Date(date.setDate(date.getDate() - 14)),
22
22
new Date()
23
23
];
24
24
}
@@ -159,7 +159,10 @@ const customShortcuts = () => {
159
159
160
160
## Localization (i18n)
161
161
162
-
Vue Tailwind Datepicker extend to day.js<br>
162
+
Vue Tailwind Datepicker now supports on-the-fly locale importing, extending to day.js. <br>
163
+
This means you only import the specific locale you need directly into your project, reducing unnecessary load of unused locales.
164
+
<br>
165
+
<br>
163
166
[List of supported locales](https://github.com/iamkun/dayjs/tree/dev/src/locale)
164
167
165
168
<DemoLayout>
@@ -174,6 +177,8 @@ Vue Tailwind Datepicker extend to day.js<br>
174
177
```vue
175
178
<script setup>
176
179
import { ref } from "vue";
180
+
// Import the specific locale from day.js
181
+
import 'dayjs/locale/fr' // Replace 'fr' with your desired locale
177
182
const dateValue = ref([]);
178
183
const options = ref({
179
184
shortcuts: {
@@ -192,7 +197,7 @@ const options = ref({
192
197
193
198
<template>
194
199
<vue-tailwind-datepicker
195
-
i18n="id"
200
+
i18n="fr"
196
201
:auto-apply="false"
197
202
:options="options"
198
203
v-model="dateValue"
Original file line number Diff line number Diff line change
@@ -3,14 +3,17 @@ import dayjs from 'dayjs'
3
3
import { ref } from 'vue'
4
4
import type { Dayjs } from 'dayjs'
5
5
import VueTailwindDatePicker from './VueTailwindDatePicker.vue'
6
+
import 'dayjs/locale/fr'
7
+
import 'dayjs/locale/de'
8
+
import 'dayjs/locale/es'
6
9
7
10
const dateValue = ref({
8
11
startDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
9
12
endDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
10
13
})
11
14
12
15
const currentLocale = ref('es')
13
-
const locales = ['en', 'es', 'de']
16
+
const locales = ['en', 'es', 'de', 'fr']
14
17
15
18
function onClickSomething(e: Dayjs) {
16
19
console.log(e)
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ import {
26
26
watch,
27
27
watchEffect,
28
28
} from 'vue'
29
-
import { localesMap } from './utils'
29
+
import 'dayjs/locale/en'
30
30
import VtdHeader from './components/Header.vue'
31
31
import VtdShortcut from './components/Shortcut.vue'
32
32
import VtdCalendar from './components/Calendar.vue'
@@ -1261,11 +1261,7 @@ watchEffect(() => {
1261
1261
const locale = props.i18n
1262
1262
const modelValueCloned = props.modelValue
1263
1263
nextTick(async () => {
1264
-
if (locale in localesMap) {
1265
-
const localeData = await localesMap[locale]()
1266
-
dayjs.locale(localeData, undefined, true)
1267
-
dayjs.locale(locale)
1268
-
}
1264
+
dayjs.locale(locale)
1269
1265
1270
1266
let s, e
1271
1267
if (asRange()) {
Original file line number Diff line number Diff line change
@@ -9,10 +9,3 @@ export function injectStrict<T>(key: InjectionKey<T>, fallback?: T) {
9
9
10
10
return resolved
11
11
}
12
-
13
-
export const localesMap = Object.fromEntries(
14
-
Object.entries(import.meta.glob('../node_modules/dayjs/esm/locale/*.js', { import: 'default' })).map(
15
-
([path, loadLocale]) => [path.match(/([\w-]*)\.js$/)?.[1], loadLocale],
16
-
),
17
-
) as Record<string, () => Promise<ILocale>>
18
-
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4