From d37ceed2ad5b94bbfc71a8a4cbdb7b498ddf724d Mon Sep 17 00:00:00 2001
From: jhzh <1628036192@qq.com>
Date: Sat, 19 Jul 2025 14:14:18 +0800
Subject: [PATCH] 1
---
src/locales/index.js | 57 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/src/locales/index.js b/src/locales/index.js
index 15044f7..5d03136 100644
--- a/src/locales/index.js
+++ b/src/locales/index.js
@@ -1,45 +1,62 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'
-import en from './en.js'
-import india from '@/locales/india'
-import tw from '@/locales/tw'
+import en from './en.json'
+import india from '@/locales/hi.json'
+import zh from '@/locales/zh.json'
+import ty from '@/locales/th.json'
+import ry from '@/locales/jp.json'
+import hy from '@/locales/kor.json'
+import de from '@/locales/de.json'
+import fra from '@/locales/fra.json'
Vue.use(VueI18n)
-
-const DEFAULT_LANG = 'zh-CN'
+const DEFAULT_LANG = window.localStorage.getItem('language') || 'ja'
const LOCALE_KEY = 'language'
-
+window.localStorage.setItem('language', DEFAULT_LANG)
const locales = {
- 'zh-CN': {
+ en: {
...en
},
- en: {
+ hi: {
...india
},
- tw: {
- ...tw
+ 'zh-CN': {
+ ...zh
+ },
+ th: {
+ ...ty
+ },
+ fr: {
+ ...fra
+ },
+ de: {
+ ...de
+ },
+ ja: {
+ ...ry
+ },
+ ko: {
+ ...hy
}
-}
+};
// en-us zh-cn
// let langLocale = getCookie(LOCALE_KEY) || 'en';
if (!window.localStorage.getItem(LOCALE_KEY)) {
window.localStorage.setItem(LOCALE_KEY, DEFAULT_LANG)
}
-let langLocale = window.localStorage.getItem(LOCALE_KEY)
- ? window.localStorage.getItem(LOCALE_KEY)
- : 'zh-CN'
+let langLocale = window.localStorage.getItem(LOCALE_KEY) || DEFAULT_LANG;
const i18n = new VueI18n({
locale: langLocale,
messages: locales,
silentTranslationWarn: true
-})
-const init = Vue.prototype._init
+});
+const init = Vue.prototype._init;
Vue.prototype._init = function (options) {
init.call(this, {
- i18n,
- ...options
- })
-}
+ i18n,
+ ...options
+ })
+};
export const setup = lang => {
if (lang === undefined) {
--
Gitblit v1.9.3