From b8f6f514b675fa6a006dfafbc99303b3c5c8ba85 Mon Sep 17 00:00:00 2001
From: dcc <dcc@163.com>
Date: Fri, 17 May 2024 10:52:12 +0800
Subject: [PATCH] 一鍵平倉增加英文多语言,IFSC改成Select recharge account
---
src/locales/index.js | 73 +++++++++++++++++++-----------------
1 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/src/locales/index.js b/src/locales/index.js
index 3c17511..c341a9e 100644
--- a/src/locales/index.js
+++ b/src/locales/index.js
@@ -1,61 +1,68 @@
-import Vue from 'vue';
-import VueI18n from 'vue-i18n';
-
-import chinese from './zh-CN.js';
-import english from './en.js';
-import chinesechar from './tw.js';
+import Vue from "vue";
+import VueI18n from "vue-i18n";
+import en from "./en.json";
+import india from "@/locales/india.json";
+import tw from "@/locales/tw.json";
+import ty from "@/locales/taiyu.json";
+import ry from "@/locales/riyu.json";
+import hy from "@/locales/hanyu.json";
Vue.use(VueI18n);
-function getCookie(name) {
- // 获取cookie
- var arr;
- var reg = new RegExp(`(^| )${name}=([^;]*)(;|$)`);
- if (arr = document.cookie.match(reg)) {
- return unescape(arr[2]);
- }
- return null;
-}
-const DEFAULT_LANG = 'en-us';
-const LOCALE_KEY = 'language';
+const DEFAULT_LANG = "en";
+const LOCALE_KEY = "language";
const locales = {
- zh_cn: {
- ...chinese,
- },
en: {
- ...english,
+ ...en
},
- tw: {
- ...chinesechar,
+ hi: {
+ ...india
},
+ "zh-TW": {
+ ...tw
+ },
+ th: {
+ ...ty
+ },
+ ja: {
+ ...ry
+ },
+ ko: {
+ ...hy
+ }
};
// en-us zh-cn
-//let langLocale = getCookie(LOCALE_KEY) || 'en';
-let langLocale = window.localStorage.getItem(LOCALE_KEY) || 'en';
-
+// 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)
+ : "en";
+console.log(langLocale)
const i18n = new VueI18n({
locale: langLocale,
messages: locales,
silentTranslationWarn: true
});
const init = Vue.prototype._init;
-Vue.prototype._init = function (options) {
+Vue.prototype._init = function(options) {
init.call(this, {
i18n,
- ...options,
+ ...options
});
};
export const setup = lang => {
if (lang === undefined) {
// lang = window.localStorage.getItem(LOCALE_KEY);
- //const language = getCookie(LOCALE_KEY);
+ // const language = getCookie(LOCALE_KEY);
const language = window.localStorage.getItem(LOCALE_KEY);
if (language) {
- langLocale = language.replace('-', '_').toLowerCase();
+ langLocale = language.replace("-", "_").toLowerCase();
}
- if (undefined !== langLocale && langLocale !== '') {
+ if (undefined !== langLocale && langLocale !== "") {
lang = langLocale;
}
if (locales[lang] === undefined) {
@@ -63,13 +70,11 @@
}
// console.log(`lang-${lang}`);
}
-
-
+ console.log(lang)
Vue.config.lang = lang;
i18n.locale = lang;
};
setup();
-
export default i18n;
--
Gitblit v1.9.3