From 2999b9b50a7e59e9aedadbe3cac4733d574abc54 Mon Sep 17 00:00:00 2001 From: Amery2010 Date: Thu, 22 Feb 2024 15:44:39 +0800 Subject: [PATCH] feat(i18n): Set the page language according to the browser default language --- src/plugins/i18n.plugin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/i18n.plugin.ts b/src/plugins/i18n.plugin.ts index 94f833da..aff1c67e 100644 --- a/src/plugins/i18n.plugin.ts +++ b/src/plugins/i18n.plugin.ts @@ -3,9 +3,11 @@ import { get } from '@vueuse/core'; import type { Plugin } from 'vue'; import { createI18n } from 'vue-i18n'; +const localeLang = navigator.language || navigator.languages[0] || 'en'; + const i18n = createI18n({ legacy: false, - locale: 'en', + locale: localeLang.split('-')[0], fallbackLocale: 'en', messages, });