英文适配
BIN
YuMi/Tools/CocoaHttpServer/Web/images/button-ar.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/button-en.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/button-id.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/button-tr.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/header-ar.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/header-en.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/header-id.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
YuMi/Tools/CocoaHttpServer/Web/images/header-tr.png
Normal file
After Width: | Height: | Size: 27 KiB |
164
YuMi/Tools/CocoaHttpServer/Web/js/getLanguage.js
Normal file
@@ -0,0 +1,164 @@
|
||||
const checkVersion = () => {
|
||||
var u = navigator.userAgent, app = navigator.appVersion;
|
||||
return {
|
||||
trident: u.indexOf('Trident') > -1, //IE内核
|
||||
presto: u.indexOf('Presto') > -1, //opera内核
|
||||
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
|
||||
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
|
||||
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
|
||||
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
|
||||
android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
|
||||
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
|
||||
iPad: u.indexOf('iPad') > -1, //是否iPad
|
||||
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
|
||||
weixin: u.indexOf('MicroMessenger') > -1, //是否微信
|
||||
qq: u.match(/\sQQ/i) == " qq", //是否QQ
|
||||
app: u.match('pekoApp') == 'pekoApp' //是否在app内
|
||||
};
|
||||
}
|
||||
|
||||
// 根据域名适配环境
|
||||
function EnvCheck() {
|
||||
if (window.location.href) {
|
||||
var _url = window.location.href;
|
||||
var res = _url.match(/uat/);
|
||||
var res1 = _url.match(/120.79.211.243/);
|
||||
var res2 = _url.match(/192.168./)
|
||||
var res3 = _url.match(/127.0/)
|
||||
var res4 = _url.match(/beta/)
|
||||
if (res || res1 || res2 || res3 || res4) {
|
||||
return 'test';
|
||||
} else {
|
||||
return 'live';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 封装 获取公共参数的方法(客户端提供)
|
||||
// written by zxfxiong
|
||||
const methodsFromClient = {
|
||||
// 注意:ios 提供的方法属异步操作
|
||||
"uid": {
|
||||
android: () => window.androidJsObj.getUid(),
|
||||
ios: function () {
|
||||
window.webkit.messageHandlers.getUid.postMessage(null);
|
||||
// let allcookies = document.cookie;
|
||||
// let $uid = allcookies.match(/\d+/);
|
||||
// console.log($uid[0]);
|
||||
}
|
||||
},
|
||||
"ticket": {
|
||||
android: () => window.androidJsObj.getTicket(),
|
||||
ios: function () {
|
||||
window.webkit.messageHandlers.getTicket.postMessage(null);
|
||||
}
|
||||
},
|
||||
"roomUid": {
|
||||
android: () => window.androidJsObj.getRoomUid(),
|
||||
ios: function () {
|
||||
window.webkit.messageHandlers.getRoomUid.postMessage(null);
|
||||
}
|
||||
},
|
||||
"deviceId": {
|
||||
android: () => window.androidJsObj.getDeviceId(),
|
||||
ios: function () {
|
||||
window.webkit.messageHandlers.getDeviceId.postMessage(null);
|
||||
}
|
||||
},
|
||||
"deviceInfo": {
|
||||
android: () => window.androidJsObj.getDeviceInfo(),
|
||||
ios: function () {
|
||||
window.webkit.messageHandlers.getDeviceInfo.postMessage(null);
|
||||
}
|
||||
},
|
||||
"encryptPwd": {
|
||||
android: (data) => window.androidJsObj.encryptPwd(data),
|
||||
ios: function (data) {
|
||||
window.webkit.messageHandlers.encryptPwd.postMessage(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 封装 在ios环境中 配置公共参数的回调函数
|
||||
// 配合 methodsFromClient[infoName].ios 方法
|
||||
// written by zxfxiong
|
||||
function getMessage(key, value) {
|
||||
pubInfo[key] = value;
|
||||
}
|
||||
// 全局获取并配置公共参数
|
||||
const pubInfo = {};
|
||||
function getInfoFromClient() {
|
||||
const browser = checkVersion();
|
||||
if (browser.app) {
|
||||
console.log('从客户端获取了用户信息(设备信息),此信息来源:common2.js');
|
||||
if (browser.android) {
|
||||
pubInfo.uid = methodsFromClient.uid.android();
|
||||
pubInfo.ticket = methodsFromClient.ticket.android();
|
||||
pubInfo.deviceId = methodsFromClient.deviceId.android();
|
||||
pubInfo.deviceInfo = methodsFromClient.deviceInfo.android();
|
||||
} else {
|
||||
methodsFromClient.uid.ios();
|
||||
methodsFromClient.ticket.ios();
|
||||
methodsFromClient.deviceId.ios();
|
||||
methodsFromClient.deviceInfo.ios();
|
||||
}
|
||||
|
||||
} else {
|
||||
// 非app环境调试参数
|
||||
pubInfo.uid = 0;
|
||||
pubInfo.ticket = "";
|
||||
pubInfo.deviceId = "0";
|
||||
pubInfo.deviceInfo = {
|
||||
'Accept-Language':'en',
|
||||
app: 'peko',
|
||||
appVersion: '0.0.0',
|
||||
os: '0.0.0',
|
||||
osVersion: '0.0.0',
|
||||
channel: 'browser',
|
||||
client: 'h5'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// 设定语言 fuzzy模糊查询客户端返回的语言
|
||||
const languageMap = [
|
||||
{ name: '简体中文', code: 'zh', fuzzy: ['zh', 'zh-Hans', 'zh-'] },
|
||||
{ name: '繁体中文', code: 'zh', fuzzy: ['zh', 'zh-Hant', 'zh-'] },
|
||||
{ name: '英语', code: 'en', fuzzy: ['en'] },
|
||||
{ name: '阿拉伯语', code: 'ar', fuzzy: ['ar', 'ar-'] },
|
||||
{ name: '印尼语', code: 'id', fuzzy: ['id', 'in', 'id-', 'in-'] },
|
||||
{ name: '土耳其语', code: 'tr', fuzzy: ['tr', 'tr-'] },
|
||||
];
|
||||
// 判断当前语言环境
|
||||
function getLanguageCode(language) {
|
||||
if (language) {
|
||||
// language = language.toLowerCase();
|
||||
for (const item of languageMap) {
|
||||
for (const list of item.fuzzy) {
|
||||
if (language.indexOf(list) != -1) {
|
||||
window.sessionStorage.setItem('language', item.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
window.sessionStorage.setItem('language', 'zh');
|
||||
}
|
||||
}
|
||||
// 判断国际化参数路径
|
||||
function fuzzyMatchUpdateQueryStringParameterFun() {
|
||||
const browser = checkVersion();
|
||||
if (browser.app) {
|
||||
if (browser.android) {
|
||||
console.log('and deviceInfo', JSON.parse(pubInfo.deviceInfo));
|
||||
getLanguageCode(JSON.parse(pubInfo.deviceInfo)["Accept-Language"]);
|
||||
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
console.log('ios deviceInfo', pubInfo.deviceInfo);
|
||||
getLanguageCode(pubInfo.deviceInfo["Accept-Language"]);
|
||||
}, 40)
|
||||
}
|
||||
} else {
|
||||
getLanguageCode();
|
||||
}
|
||||
}
|
49
YuMi/Tools/CocoaHttpServer/Web/js/langHandler.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 初始化当前语言
|
||||
*/
|
||||
function initLocalLang () {
|
||||
const lang = sessionStorage.getItem('language')
|
||||
console.log('getSessionLang',lang);
|
||||
if (lang === 'zh' || window.location.href.match('=zh')) {
|
||||
console.log("langHandler" + '繁体')
|
||||
window.lang = langZh
|
||||
window.lang.code = 'zh'
|
||||
window.lang.defaults = false
|
||||
} else if (lang === 'ar' || window.location.href.match('=ar')) {
|
||||
// 阿拉伯
|
||||
console.log("langHandler" + '阿拉伯')
|
||||
window.lang = langAr
|
||||
window.lang.code = 'ar'
|
||||
window.lang.defaults = false
|
||||
} else if (lang === 'en' || window.location.href.match('=en')) {
|
||||
// 英语
|
||||
console.log("langHandler" + '英语')
|
||||
window.lang = langEn
|
||||
window.lang.code = 'en'
|
||||
window.lang.defaults = false
|
||||
} else if (lang === 'id' || window.location.href.match('=id')) {
|
||||
// 印度尼西亚
|
||||
console.log("langHandler" + '印尼')
|
||||
window.lang = langId
|
||||
window.lang.code = 'Id'
|
||||
window.lang.defaults = false
|
||||
}else if (lang === 'tr' || window.location.href.match('=tr')) {
|
||||
// 土耳其
|
||||
console.log("langHandler" + '土耳其')
|
||||
window.lang = langTr
|
||||
window.lang.code = 'Tr'
|
||||
window.lang.defaults = false
|
||||
} else {
|
||||
console.log("langHandler" + '默认')
|
||||
window.lang = langZh
|
||||
window.lang.code = null
|
||||
window.lang.defaults = true
|
||||
}
|
||||
|
||||
window.lang.replace = (Lang, defaultText) => {
|
||||
if (Lang) {
|
||||
return Lang
|
||||
}
|
||||
return defaultText
|
||||
}
|
||||
}
|
10
YuMi/Tools/CocoaHttpServer/Web/local/ar.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// 阿拉伯
|
||||
langAr = {
|
||||
demoModule: {
|
||||
// ===============index============
|
||||
song_title:'بنقرة واحدة تحميل الأغاني',
|
||||
song_list: 'قائمة الأغاني',
|
||||
headerImg:'images/header-ar.png',
|
||||
btnImg:'images/button-ar.png',
|
||||
}
|
||||
}
|
10
YuMi/Tools/CocoaHttpServer/Web/local/en.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// 英文
|
||||
langEn = {
|
||||
demoModule: {
|
||||
// ===============index============
|
||||
song_title:'One-click upload of songs',
|
||||
song_list: 'Song list',
|
||||
headerImg:'images/header-en.png',
|
||||
btnImg:'images/button-en.png',
|
||||
}
|
||||
}
|
10
YuMi/Tools/CocoaHttpServer/Web/local/id.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// 印尼语
|
||||
langId = {
|
||||
demoModule: {
|
||||
// ===============index============
|
||||
song_title:'Unggah lagu dengan satu klik',
|
||||
song_list: 'Daftar lagu',
|
||||
headerImg:'images/header-id.png',
|
||||
btnImg:'images/button-id.png',
|
||||
}
|
||||
}
|
10
YuMi/Tools/CocoaHttpServer/Web/local/tr.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// 土耳其语
|
||||
langTr = {
|
||||
demoModule: {
|
||||
// ===============index============
|
||||
song_title:'Tek tıklamayla şarkı yükleyin',
|
||||
song_list: 'şarkı listesi',
|
||||
headerImg:'images/header-tr.png',
|
||||
btnImg:'images/button-tr.png',
|
||||
}
|
||||
}
|
10
YuMi/Tools/CocoaHttpServer/Web/local/zh.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// 繁体中文
|
||||
langZh = {
|
||||
demoModule: {
|
||||
// ===============index============
|
||||
song_title:'一鍵上傳歌曲',
|
||||
song_list: '歌曲列表',
|
||||
headerImg:'images/header.png',
|
||||
btnImg:'images/button.png',
|
||||
}
|
||||
}
|