diff --git a/frontend/composables/use-preferences.ts b/frontend/composables/use-preferences.ts index 8cb4b370..1c957459 100644 --- a/frontend/composables/use-preferences.ts +++ b/frontend/composables/use-preferences.ts @@ -11,6 +11,7 @@ export type LocationViewPreferences = { theme: DaisyTheme; itemsPerTablePage: number; displayHeaderDecor: boolean; + language?: string; }; /** @@ -28,6 +29,7 @@ export function useViewPreferences(): Ref { theme: "homebox", itemsPerTablePage: 10, displayHeaderDecor: true, + language: null, }, { mergeDefaults: true } ); diff --git a/frontend/locales/en.json b/frontend/locales/en.json index d2b130d5..0301b6cc 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -124,7 +124,9 @@ "url": "URL", "user_profile": "User Profile", "user_profile_sub": "Invite users, and manage your account.", - "display_header": "{ currentValue, select, true {Hide Header} false {Show Header} other {Not Hit}}" + "display_header": "{ currentValue, select, true {Hide Header} false {Show Header} other {Not Hit}}", + "language": "Language", + "update_language": "Update Language" }, "tools": { "reports": "Reports", @@ -163,5 +165,25 @@ "set_primary_photo_sub": "In version v0.10.0 of Homebox, the primary image field was added to attachments of type photo. This action will set the primary image field to the first image in the attachments array in the database, if it is not already set. ''See GitHub PR #576''", "set_primary_photo_button": "Set Primary Photo" } + }, + "languages": { + "ca": "Catalan", + "de": "German", + "en": "English", + "es": "Spanish", + "fr": "French", + "hu": "Hungarian", + "it": "Italian", + "nl": "Dutch", + "pl": "Polish", + "pt-BR": "Portuguese (Brazil)", + "ru": "Russian", + "sl": "Slovenian", + "sv": "Swedish", + "tr": "Turkish", + "zh-CN": "Chinese (Simplified)", + "zh-HK": "Chinese (Hong Kong)", + "zh-MO": "Chinese (Macau)", + "zh-TW": "Chinese (Traditional)" } } \ No newline at end of file diff --git a/frontend/pages/profile.vue b/frontend/pages/profile.vue index 2be7ad32..8872cb5d 100644 --- a/frontend/pages/profile.vue +++ b/frontend/pages/profile.vue @@ -8,7 +8,6 @@ import MdiFill from "~icons/mdi/fill"; import MdiPencil from "~icons/mdi/pencil"; import MdiAccountMultiple from "~icons/mdi/account-multiple"; - import type {ViewType} from "~/composables/use-preferences"; definePageMeta({ middleware: ["auth"], @@ -35,6 +34,9 @@ function setDisplayHeader() { preferences.value.displayHeaderDecor = !preferences.value.displayHeaderDecor; } + function setLanguage(lang: string) { + preferences.value.language = lang; + } // Currency Selection const currency = ref({ @@ -370,6 +372,19 @@ {{ token }} +
+ + +
+ {{ $t("profile.update_language") }} +
+
diff --git a/frontend/plugins/i18n.ts b/frontend/plugins/i18n.ts index 54939e5b..f0faae5e 100644 --- a/frontend/plugins/i18n.ts +++ b/frontend/plugins/i18n.ts @@ -20,11 +20,12 @@ export default defineNuxtPlugin(({ vueApp }) => { } return matched; } + const preferences = useViewPreferences(); const i18n = createI18n({ fallbackLocale: "en", globalInjection: true, legacy: false, - locale: checkDefaultLanguage() || "en", + locale: preferences.value.language || checkDefaultLanguage() || "en", messageCompiler, messages: messages(), });