From 2ad80b3082de16db2d633823a22a7d57cb01f695 Mon Sep 17 00:00:00 2001 From: huaiyuan <1029848564@qq.com> Date: Thu, 5 Sep 2024 16:38:51 +0800 Subject: [PATCH] fix: Support language meta --- packages/frontend/src/App.vue | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/App.vue b/packages/frontend/src/App.vue index 5369be8..ae0ea92 100644 --- a/packages/frontend/src/App.vue +++ b/packages/frontend/src/App.vue @@ -6,7 +6,8 @@ import { defineComponent, onMounted } from 'vue'; import { useTokenStore } from './stores/token'; import { CurrentView } from 'src/constants/index'; - +import { supportLanguages } from './i18n'; +import { i18n } from './boot/i18n'; import queryString from 'query-string'; export default defineComponent({ @@ -53,6 +54,23 @@ export default defineComponent({ } }); + let terminusLanguage = ''; + let terminusLanguageInfo = document.querySelector( + 'meta[name="terminus-language"]' + ); + if (terminusLanguageInfo && terminusLanguageInfo.content) { + terminusLanguage = terminusLanguageInfo.content; + } else { + terminusLanguage = navigator.language; + } + + console.log(navigator.language); + + if (terminusLanguage) { + if (supportLanguages.find((e) => e.value == terminusLanguage)) { + i18n.global.locale.value = terminusLanguage; + } + } return {}; } });