Skip to content

Commit 0bbe754

Browse files
author
Your Name
committed
feat: refactor locale handling in settings to fix CI type test failing
1 parent 4cd45c2 commit 0bbe754

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

app/pages/settings.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
<script setup lang="ts">
22
const router = useRouter()
33
const { settings } = useSettings()
4-
const { locale: currentLocale, locales, setLocale: setNuxti18nLocale } = useI18n()
4+
const { locale, locales, setLocale: setNuxti18nLocale } = useI18n()
55
const colorMode = useColorMode()
66
const { currentLocaleStatus, isSourceLocale } = useI18nStatus()
77
const keyboardShortcutsEnabled = useKeyboardShortcuts()
88
const { toggleCodeLigatures } = useCodeLigatures()
99
10+
// Create a computed property to handle locale binding properly
11+
const currentLocale = computed<string>({
12+
get: () => locale.value as string,
13+
set: (newLocale: string) => {
14+
if (newLocale) {
15+
settings.value.selectedLocale = newLocale as any
16+
setNuxti18nLocale(newLocale as any)
17+
}
18+
},
19+
})
20+
1021
// Escape to go back (but not when focused on form elements or modal is open)
1122
onKeyStroke(
1223
e =>
@@ -35,16 +46,6 @@ defineOgImageComponent('Default', {
3546
description: () => $t('settings.tagline'),
3647
primaryColor: '#60a5fa',
3748
})
38-
39-
const setLocale: typeof setNuxti18nLocale = newLocale => {
40-
settings.value.selectedLocale = newLocale
41-
return setNuxti18nLocale(newLocale)
42-
}
43-
44-
function handleLocaleChange(newLocale?: string) {
45-
if (!newLocale) return
46-
setLocale(newLocale)
47-
}
4849
</script>
4950

5051
<template>
@@ -249,8 +250,7 @@ function handleLocaleChange(newLocale?: string) {
249250
<SelectField
250251
id="language-select"
251252
:items="locales.map(loc => ({ label: loc.name ?? '', value: loc.code }))"
252-
:modelValue="currentLocale"
253-
@update:modelValue="handleLocaleChange"
253+
v-model="currentLocale"
254254
block
255255
size="sm"
256256
class="max-w-48"

0 commit comments

Comments
 (0)