feat: datepicker locale support (#3878)
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/3878 Reviewed-by: konrad <k@knt.li> Co-authored-by: nor <zorodey@outlook.com> Co-committed-by: nor <zorodey@outlook.com>
This commit is contained in:
15
src/helpers/flatpickrLanguage.ts
Normal file
15
src/helpers/flatpickrLanguage.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {useAuthStore} from '@/stores/auth'
|
||||
import FlatpickrLanguages from 'flatpickr/dist/l10n'
|
||||
import type { CustomLocale, key } from 'flatpickr/dist/types/locale'
|
||||
|
||||
export function getFlatpickrLanguage(): CustomLocale {
|
||||
const authStore = useAuthStore()
|
||||
const lang = authStore.settings.language
|
||||
const langPair = lang.split('-')
|
||||
let language = FlatpickrLanguages[lang === 'vi-vn' ? 'vn' : 'en']
|
||||
if (langPair.length > 0 && FlatpickrLanguages[langPair[0] as key] !== undefined) {
|
||||
language = FlatpickrLanguages[langPair[0] as key]
|
||||
}
|
||||
language.firstDayOfWeek = authStore.settings.weekStart ?? language.firstDayOfWeek
|
||||
return language
|
||||
}
|
Reference in New Issue
Block a user