Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b23c21d05b | |||
| 65a24f25bb | |||
| 2a0935b581 | |||
| b31197a8b4 |
@@ -54,6 +54,14 @@ function loadLangPackSync(lang, path) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前本地语言
|
||||
* @returns
|
||||
*/
|
||||
function getCurrentLocale() {
|
||||
return uni.getStorageSync('lang') || "zh-cn";
|
||||
}
|
||||
|
||||
export default {
|
||||
langList: langConfig.langList,
|
||||
|
||||
@@ -61,9 +69,7 @@ export default {
|
||||
* 获得当前本地语言
|
||||
* @returns
|
||||
*/
|
||||
getCurrentLocale() {
|
||||
return uni.getStorageSync('lang') || "zh-cn";
|
||||
},
|
||||
getCurrentLocale,
|
||||
|
||||
/**
|
||||
* * 解析多语言
|
||||
@@ -73,7 +79,7 @@ export default {
|
||||
let _page = getCurrentPages()[getCurrentPages().length - 1];
|
||||
if (!_page) return;
|
||||
|
||||
const locale = this.getCurrentLocale(); // 获得当前本地语言
|
||||
const locale = getCurrentLocale(); // 获得当前本地语言
|
||||
|
||||
let value = ''; // 存放解析后的语言值
|
||||
let langPath = ''; // 存放当前页面语言包路径
|
||||
@@ -141,7 +147,7 @@ export default {
|
||||
if (!_page) return;
|
||||
|
||||
uni.setStorageSync("lang", value);
|
||||
const locale = this.getCurrentLocale();
|
||||
const locale = getCurrentLocale();
|
||||
|
||||
// 清空已加载的语言包缓存
|
||||
for (let key in loadedLangPacks) {
|
||||
@@ -161,7 +167,7 @@ export default {
|
||||
let _page = getCurrentPages()[getCurrentPages().length - 1];
|
||||
if (!_page) return;
|
||||
|
||||
const locale = this.getCurrentLocale();
|
||||
const locale = getCurrentLocale();
|
||||
|
||||
this.title(this.lang("title"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user