yh-i18n 2.0.0 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +7 -0
- package/index.js +6 -21
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { I18n } from "vue-i18n";
|
|
2
|
+
import { Plugin, Component } from "vue";
|
|
2
3
|
import { StoreDefinition } from "pinia";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -24,3 +25,9 @@ export const ct: (key: string, args: any[]) => void;
|
|
|
24
25
|
|
|
25
26
|
/** 国际化相关 Pinia Store 实例 */
|
|
26
27
|
export const useI18nStore: StoreDefinition;
|
|
28
|
+
|
|
29
|
+
/** 力控远海 vue-i18n 插件封装 */
|
|
30
|
+
export const yhI18n: Plugin;
|
|
31
|
+
|
|
32
|
+
/** 多语言选择插件 */
|
|
33
|
+
export const Language: Component;
|
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ const navLang = navigator.language.replace("-", "_");
|
|
|
29
29
|
const initlang = localStorage.translateLanguage || navLang || "zh_CN";
|
|
30
30
|
|
|
31
31
|
export let i18n = null;
|
|
32
|
-
window.translateReady =
|
|
32
|
+
window.translateReady = localStorage.translateReady ? localStorage.translateReady === "1" : import.meta.env.DEV;
|
|
33
33
|
const isDev = window.translateReady;
|
|
34
34
|
|
|
35
35
|
const keySet = new Set();
|
|
@@ -248,17 +248,9 @@ export function addI18nPage(router) {
|
|
|
248
248
|
|
|
249
249
|
export function cLog(string, isError = false) {
|
|
250
250
|
if (isError) {
|
|
251
|
-
console.error(
|
|
252
|
-
"%cyhI18n:",
|
|
253
|
-
"font-size: 16px;font-weight: bold;color: #61AFEF",
|
|
254
|
-
string
|
|
255
|
-
);
|
|
251
|
+
console.error("%cyhI18n:", "font-size: 16px;font-weight: bold;color: #61AFEF", string);
|
|
256
252
|
} else {
|
|
257
|
-
console.log(
|
|
258
|
-
"%cYHI18n",
|
|
259
|
-
"font-size: 18px;font-weight: bold;color: #61AFEF",
|
|
260
|
-
string
|
|
261
|
-
);
|
|
253
|
+
console.log("%cYHI18n", "font-size: 18px;font-weight: bold;color: #61AFEF", string);
|
|
262
254
|
}
|
|
263
255
|
}
|
|
264
256
|
|
|
@@ -266,9 +258,7 @@ export const yhI18n = {
|
|
|
266
258
|
install(app, config) {
|
|
267
259
|
let { list, router, pinia, VXETable } = config;
|
|
268
260
|
if (!list) {
|
|
269
|
-
cLog(
|
|
270
|
-
"请设置 Config.i18nList ,并将其设置到 yhI18n 的 congfig.list 上,否则 国际化插件将失效"
|
|
271
|
-
);
|
|
261
|
+
cLog("请设置 Config.i18nList ,并将其设置到 yhI18n 的 congfig.list 上,否则 国际化插件将失效");
|
|
272
262
|
return false;
|
|
273
263
|
}
|
|
274
264
|
let messages = createLocalMessage(list);
|
|
@@ -280,9 +270,7 @@ export const yhI18n = {
|
|
|
280
270
|
app.config.globalProperties.$T = ct;
|
|
281
271
|
|
|
282
272
|
if (!isDev) {
|
|
283
|
-
cLog(
|
|
284
|
-
"没有开启翻译管理,可以在开发环境或者在控制台运行后面的代码再刷新页面: `localStorage.translateLanguage = '1'`"
|
|
285
|
-
);
|
|
273
|
+
cLog("没有开启翻译管理,可以在开发环境或者在控制台运行后面的代码再刷新页面: `localStorage.translateLanguage = '1'`");
|
|
286
274
|
}
|
|
287
275
|
if (router && isDev) {
|
|
288
276
|
addI18nPage(router);
|
|
@@ -307,10 +295,7 @@ export const yhI18n = {
|
|
|
307
295
|
});
|
|
308
296
|
} else {
|
|
309
297
|
if (!pinia) {
|
|
310
|
-
cLog(
|
|
311
|
-
"没有传递 VXETable 对象,所以无法为 SLW 和 VXETable 设置国际化",
|
|
312
|
-
true
|
|
313
|
-
);
|
|
298
|
+
cLog("没有传递 VXETable 对象,所以无法为 SLW 和 VXETable 设置国际化", true);
|
|
314
299
|
}
|
|
315
300
|
}
|
|
316
301
|
|