mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
34 lines
965 B
TypeScript
34 lines
965 B
TypeScript
import { setLocale } from 'yup'
|
|
import { usePreferedLocale, usePreferedTheme } from '@/composables/states'
|
|
|
|
export default defineNuxtPlugin({
|
|
async setup() {
|
|
// Override default yup errors
|
|
// https://github.com/jquense/yup/blob/master/src/locale.ts
|
|
setLocale({
|
|
mixed: {
|
|
default: 'v.field_invalid',
|
|
required: 'v.field_required',
|
|
},
|
|
string: {
|
|
email: 'v.email',
|
|
min: ({ min }) => ({ key: 'v.string_too_short', values: { min } }),
|
|
},
|
|
})
|
|
|
|
const preferedTheme = await usePreferedTheme()
|
|
const colorMode = useColorMode()
|
|
if (preferedTheme.value !== 'auto') {
|
|
colorMode.preference = preferedTheme.value
|
|
}
|
|
},
|
|
hooks: {
|
|
'app:created'() {
|
|
// Override browser locale if prefered language
|
|
const preferedLocale = usePreferedLocale()
|
|
if (preferedLocale.value !== 'auto') {
|
|
useNuxtApp().$i18n.locale.value = preferedLocale.value
|
|
}
|
|
},
|
|
},
|
|
})
|