多语言优化
parent
b2f5ae64b9
commit
21762369f2
17
App.vue
17
App.vue
|
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import base64 from './common/js/lib/base64.js';
|
import base64 from './common/js/lib/base64.js';
|
||||||
// 多语言引入并初始化
|
// 多语言引入并初始化
|
||||||
import i18n from './lang/index';
|
import i18n from './locale/index';
|
||||||
export default {
|
export default {
|
||||||
globalData: {
|
globalData: {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
// 增加或者减少语言时
|
// 增加或者减少语言时
|
||||||
// 1.新增一个对象,按照当前格式新增
|
// 1.新增一个对象,按照当前格式新增
|
||||||
// 2.去lang里面各个文件去新增语言翻译
|
// 2.去lang里面各个文件去新增语言翻译
|
||||||
default_language: 'zh-Hans',
|
default_language: 'zh',
|
||||||
|
|
||||||
// tabbar页面
|
// tabbar页面
|
||||||
tabbar_pages: ['/pages/index/index', '/pages/goods-category/goods-category', '/pages/cart/cart', '/pages/user/user'],
|
tabbar_pages: ['/pages/index/index', '/pages/goods-category/goods-category', '/pages/cart/cart', '/pages/user/user'],
|
||||||
|
|
@ -322,17 +322,8 @@
|
||||||
var user_location = this.choice_user_location_init();
|
var user_location = this.choice_user_location_init();
|
||||||
var user_location_params = (user_location || null) != null && (user_location.status || 0) == 1 ? '&user_lng=' + user_location.lng + '&user_lat=' + user_location.lat : '';
|
var user_location_params = (user_location || null) != null && (user_location.status || 0) == 1 ? '&user_lng=' + user_location.lng + '&user_lat=' + user_location.lat : '';
|
||||||
// 当前语言
|
// 当前语言
|
||||||
var lang_list = {
|
var lang = this.get_language_value();
|
||||||
'zh-Hans': 'zh',
|
|
||||||
'zh-Hant': 'cht',
|
|
||||||
en: 'en',
|
|
||||||
fr: 'fra',
|
|
||||||
es: 'spa',
|
|
||||||
};
|
|
||||||
var lang = lang_list[this.get_language_value()] || null;
|
|
||||||
if (lang == null) {
|
|
||||||
lang = 'zh';
|
|
||||||
}
|
|
||||||
// 拼接标识
|
// 拼接标识
|
||||||
var join = url.indexOf('?') == -1 ? '?' : '&';
|
var join = url.indexOf('?') == -1 ? '?' : '&';
|
||||||
return url + join + 'system_type=' + this.data.system_type + '&application=app&application_client_type=' + client_value + '&token=' + token + '&uuid=' + uuid + referrer_params + user_location_params + '&lang=' + lang;
|
return url + join + 'system_type=' + this.data.system_type + '&application=app&application_client_type=' + client_value + '&token=' + token + '&uuid=' + uuid + referrer_params + user_location_params + '&lang=' + lang;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"language": {
|
"language": {
|
||||||
"zh-Hans": "Simplified Chinese",
|
"zh": "Simplified Chinese",
|
||||||
"en": "English"
|
"en": "English"
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import VueI18n from 'vue-i18n';
|
import VueI18n from 'vue-i18n';
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
|
||||||
import zhHans from './zh.json';
|
import zh from './zh.json';
|
||||||
import en from './en.json';
|
import en from './en.json';
|
||||||
|
|
||||||
let i18nConfig = {
|
let i18nConfig = {
|
||||||
locale: uni.getLocale(),
|
locale: uni.getLocale(),
|
||||||
silentTranslationWarn: true,
|
silentTranslationWarn: true,
|
||||||
messages: {
|
messages: {
|
||||||
"zh-Hans": zhHans,
|
"zh": zh,
|
||||||
"en": en
|
"en": en
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"language": {
|
"language": {
|
||||||
"zh-Hans": "简体中文",
|
"zh": "简体中文",
|
||||||
"en": "英语"
|
"en": "英语"
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
2
main.js
2
main.js
|
|
@ -6,7 +6,7 @@ import base from './common/js/common/base';
|
||||||
import share from './common/js/common/share';
|
import share from './common/js/common/share';
|
||||||
|
|
||||||
// 多语言引入并初始化
|
// 多语言引入并初始化
|
||||||
import i18n from './lang/index'
|
import i18n from './locale/index'
|
||||||
|
|
||||||
// 全局icon组件
|
// 全局icon组件
|
||||||
import iconfont from './components/iconfont/iconfont.vue'
|
import iconfont from './components/iconfont/iconfont.vue'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue