diff --git a/app.vue b/app.vue
index f378be87..5bcb88be 100644
--- a/app.vue
+++ b/app.vue
@@ -1,5 +1,6 @@
@@ -24,7 +18,7 @@ const handleLocale = async (locale: string) => {
v-for="item in locales"
:key="item.code"
:checked="item.code === locale"
- @click="handleLocale(item.code)"
+ @click="setLocale(item.code)"
>
{{ item.name }}
diff --git a/components/user/UserSwitcher.vue b/components/user/UserSwitcher.vue
index 12365410..8a0ae455 100644
--- a/components/user/UserSwitcher.vue
+++ b/components/user/UserSwitcher.vue
@@ -14,7 +14,8 @@ const router = useRouter()
const switchUser = (user: UserLogin) => {
if (user.account.id === currentUser.value?.account.id)
router.push(getAccountPath(user.account))
- else loginTo(user)
+ else
+ loginTo(user)
}
diff --git a/composables/page-header.ts b/composables/setups.ts
similarity index 57%
rename from composables/page-header.ts
rename to composables/setups.ts
index bb21b15c..dab9581e 100644
--- a/composables/page-header.ts
+++ b/composables/setups.ts
@@ -1,10 +1,11 @@
-import { APP_NAME } from '~/constants'
+import { APP_NAME, STORAGE_KEY_LANG } from '~/constants'
const isDev = process.dev
const isPreview = window.location.hostname.includes('deploy-preview')
-export function usePageHeader() {
+export function setupPageHeader() {
const i18n = useI18n()
+
useHeadFixed({
htmlAttrs: {
lang: () => i18n.locale.value,
@@ -21,3 +22,17 @@ export function usePageHeader() {
// eslint-disable-next-line no-unused-expressions
isDark.value
}
+
+export async function setupI18n() {
+ // TODO: guess user language
+
+ const { locale, setLocale } = useI18n()
+ const localeStorage = useLocalStorage(STORAGE_KEY_LANG, locale.value)
+
+ if (localeStorage.value !== locale.value)
+ await setLocale(localeStorage.value)
+
+ watchEffect(() => {
+ localeStorage.value = locale.value
+ })
+}
diff --git a/error.vue b/error.vue
index bc5bd593..8ba07296 100644
--- a/error.vue
+++ b/error.vue
@@ -6,7 +6,7 @@ const { error } = defineProps<{
error: Partial
}>()
-usePageHeader()
+setupPageHeader()
// add more custom status codes messages here
const errorCodes: Record = {
diff --git a/nuxt.config.ts b/nuxt.config.ts
index edb3cc66..85c766ce 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -104,8 +104,7 @@ export default defineNuxtConfig({
vueI18n: {
fallbackLocale: 'en-US',
},
- // TODO:
- // lazy: true,
+ lazy: true,
},
})