rebuild card info translations

This commit is contained in:
WEBXOSS 2017-04-09 20:22:48 +08:00
parent 8ec1044538
commit 22b0d92fac
8 changed files with 50222 additions and 30 deletions

View file

@ -8,8 +8,6 @@
global = window; global = window;
</script> </script>
<script src="../../CardInfo.js"></script> <script src="../../CardInfo.js"></script>
<script src="../CardInfo_ru.js"></script>
<script src="../CardInfo_ko.js"></script>
<link rel="stylesheet" type="text/css" href="editor.css"> <link rel="stylesheet" type="text/css" href="editor.css">
</head> </head>

View file

@ -1,8 +1,75 @@
'use strict'; 'use strict';
window.Localize = (function () { window.Localize = (function () {
// Load translations
(function () {
function get(url, succ, err) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.onload = function () {
if (xhr.status === 200) {
succ(xhr.response);
} else {
if (err) err(xhr);
}
}
xhr.onerror = function () {
if (err) err(xhr);
};
xhr.open('GET', url, true);
xhr.send();
}
window.CardInfo_jp = Object.create(CardInfo);
window.CardInfo_zh = Object.create(CardInfo);
window.CardInfo_en = Object.create(CardInfo);
window.CardInfo_ko = Object.create(CardInfo);
window.CardInfo_ru = Object.create(CardInfo);
window.CardInfo_it = Object.create(CardInfo);
var dir = location.pathname.match(/\/DeckEditor\/?$/) ? '../lang/' : './lang/'
get(dir + 'CardInfo_en.json', function (translation) {
for (var pid in translation) {
var tran = translation[pid];
var info = Object.create(CardInfo_jp[pid]);
for (var prop in tran) {
info[prop] = tran[prop];
}
window.CardInfo_en[pid] = info;
window.CardInfo_it[pid] = info;
}
})
get(dir + 'CardInfo_zh_CN.json', function (translation) {
for (var pid in translation) {
var tran = translation[pid];
var info = Object.create(CardInfo_jp[pid]);
for (var prop in tran) {
info[prop] = tran[prop];
}
window.CardInfo_zh[pid] = info;
}
})
get(dir + 'CardInfo_ru.json', function (translation) {
for (var pid in translation) {
var tran = translation[pid];
var info = Object.create(CardInfo_jp[pid]);
for (var prop in tran) {
info[prop] = tran[prop];
}
window.CardInfo_ru[pid] = info;
}
})
get(dir + 'CardInfo_ko.json', function (translation) {
for (var pid in translation) {
var tran = translation[pid];
var info = Object.create(CardInfo_jp[pid]);
for (var prop in tran) {
info[prop] = tran[prop];
}
window.CardInfo_ko[pid] = info;
}
})
})();
var map_zh_CN = { var map_zh_CN = {
suffix: '_zh_CN',
common: { common: {
'OK': '确定', 'OK': '确定',
'CANCEL': '取消', 'CANCEL': '取消',
@ -368,7 +435,6 @@ var map_zh_CN = {
}; };
var map_en = { var map_en = {
suffix: '_en',
common: { common: {
'OK': 'OK', 'OK': 'OK',
'CANCEL': 'CANCEL', 'CANCEL': 'CANCEL',
@ -734,7 +800,6 @@ var map_en = {
}; };
var map_jp = { var map_jp = {
suffix: '',
common: { common: {
'OK': 'OK', 'OK': 'OK',
'CANCEL': 'キャンセル', 'CANCEL': 'キャンセル',
@ -1121,7 +1186,6 @@ var map_jp = {
}; };
var map_ru = { var map_ru = {
suffix: '_ru',
common: { common: {
'OK': 'OK', 'OK': 'OK',
'CANCEL': 'Отмена', 'CANCEL': 'Отмена',
@ -1489,7 +1553,6 @@ var map_ru = {
}; };
var map_it = { var map_it = {
suffix: '_en',
common: { common: {
'OK': 'OK', 'OK': 'OK',
'CANCEL': 'CANCEL', 'CANCEL': 'CANCEL',
@ -1855,7 +1918,6 @@ var map_it = {
}; };
var map_ko = { var map_ko = {
suffix: '_ko',
common: { common: {
'OK': '확인', 'OK': '확인',
'CANCEL': '캔슬', 'CANCEL': '캔슬',
@ -2281,28 +2343,36 @@ Localize.getLanguage = function () {
Localize.setLanguage = function (lang) { Localize.setLanguage = function (lang) {
if (lang === 'zh_CN') { if (lang === 'zh_CN') {
Localize.map = map_zh_CN; Localize.map = map_zh_CN;
CardInfo = CardInfo_zh;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else if (lang === 'zh_TW') { } else if (lang === 'zh_TW') {
Localize.map = map_zh_TW; Localize.map = map_zh_TW;
CardInfo = CardInfo_zh;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else if (lang === 'en') { } else if (lang === 'en') {
Localize.map = map_en; Localize.map = map_en;
CardInfo = CardInfo_en;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else if (lang === 'jp') { } else if (lang === 'jp') {
Localize.map = map_jp; Localize.map = map_jp;
CardInfo = CardInfo_jp;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else if (lang === 'ko') { } else if (lang === 'ko') {
Localize.map = map_ko; Localize.map = map_ko;
CardInfo = CardInfo_ko;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else if (lang === 'ru') { } else if (lang === 'ru') {
Localize.map = map_ru; Localize.map = map_ru;
CardInfo = CardInfo_ru;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else if (lang === 'it') { } else if (lang === 'it') {
Localize.map = map_it; Localize.map = map_it;
CardInfo = CardInfo_it;
localStorage.setItem('language',lang); localStorage.setItem('language',lang);
} else { } else {
debugger; debugger;
Localize.map = map_en; Localize.map = map_en;
CardInfo = CardInfo_jp;
} }
}; };
@ -2329,10 +2399,6 @@ Localize.traditionalize = function (str) {
return newStr; return newStr;
}; };
Localize.suffix = function (str) {
return str + Localize.map.suffix;
};
Localize.index = Localize.bind(Localize,'index'); Localize.index = Localize.bind(Localize,'index');
Localize.editor = Localize.bind(Localize,'editor'); Localize.editor = Localize.bind(Localize,'editor');
@ -2415,7 +2481,7 @@ Localize.color = function (color) {
}; };
Localize.cardName = function (info) { Localize.cardName = function (info) {
return Localize.traditionalize(info[Localize.suffix('name')]); return Localize.traditionalize(info['name']);
}; };
Localize.cardType = function (info) { Localize.cardType = function (info) {
@ -2425,7 +2491,7 @@ Localize.cardType = function (info) {
Localize.effectTexts = function (info) { Localize.effectTexts = function (info) {
info = CardInfo[info.cid]; info = CardInfo[info.cid];
// 额外 // 额外
var texts = concat(info[Localize.suffix('extraTexts')] || []); var texts = concat(info['extraTexts'] || []);
// 防御 // 防御
if (info.guardFlag) { if (info.guardFlag) {
texts.push(Localize('_misc','GUARD_DESCRIPTION')); texts.push(Localize('_misc','GUARD_DESCRIPTION'));
@ -2450,12 +2516,12 @@ Localize.effectTexts = function (info) {
texts.push(Localize('_misc','CROSS_RIGHT',toNames(info.crossRight))); texts.push(Localize('_misc','CROSS_RIGHT',toNames(info.crossRight)));
} }
// 魔法技艺 // 魔法技艺
[Localize.suffix('spellEffectTexts'),Localize.suffix('artsEffectTexts')].forEach(function (prop) { ['spellEffectTexts','artsEffectTexts'].forEach(function (prop) {
if (!info[prop]) return; if (!info[prop]) return;
texts.push(info[prop][0]); texts.push(info[prop][0]);
},this); },this);
// 常出起 // 常出起
[Localize.suffix('constEffectTexts'),Localize.suffix('startUpEffectTexts'),Localize.suffix('actionEffectTexts')].forEach(function (prop) { ['constEffectTexts','startUpEffectTexts','actionEffectTexts'].forEach(function (prop) {
if (!info[prop]) return; if (!info[prop]) return;
texts = texts.concat(info[prop]); texts = texts.concat(info[prop]);
},this); },this);
@ -2464,8 +2530,8 @@ Localize.effectTexts = function (info) {
Localize.burstEffectTexts = function (info) { Localize.burstEffectTexts = function (info) {
info = CardInfo[info.cid]; info = CardInfo[info.cid];
if (!info[Localize.suffix('burstEffectTexts')]) return '-'; if (!info['burstEffectTexts']) return '-';
return Localize.traditionalize(info[Localize.suffix('burstEffectTexts')][0]); return Localize.traditionalize(info['burstEffectTexts'][0]);
}; };
Localize.guard = function (info) { Localize.guard = function (info) {
@ -2526,15 +2592,15 @@ Localize.desc = function (desc) {
if (!info) { if (!info) {
debugger; debugger;
return desc; return desc;
} }ƒ
var map = { var map = {
'const': info[Localize.suffix('constEffectTexts')], 'const': info['constEffectTexts'],
'spell': info[Localize.suffix('spellEffectTexts')], 'spell': info['spellEffectTexts'],
'arts': info[Localize.suffix('artsEffectTexts')], 'arts': info['artsEffectTexts'],
'burst': info[Localize.suffix('burstEffectTexts')], 'burst': info['burstEffectTexts'],
'startup': info[Localize.suffix('startUpEffectTexts')], 'startup': info['startUpEffectTexts'],
'action': info[Localize.suffix('actionEffectTexts')], 'action': info['actionEffectTexts'],
'attached': info[Localize.suffix('attachedEffectTexts')] 'attached': info['attachedEffectTexts']
}; };
if (!map[type] || !map[type][idx]) { if (!map[type] || !map[type][idx]) {
debugger; debugger;

View file

@ -255,8 +255,6 @@
<script src="./lib/easeljs-0.8.2.min.js" defer="defer"></script> <script src="./lib/easeljs-0.8.2.min.js" defer="defer"></script>
<script src="./socket.io.min.js" defer="defer"></script> <script src="./socket.io.min.js" defer="defer"></script>
<script src="../CardInfo.js" defer="defer"></script> <script src="../CardInfo.js" defer="defer"></script>
<script src="./CardInfo_ru.js" defer="defer"></script>
<script src="./CardInfo_ko.js" defer="defer"></script>
<!-- <script src="./Localize.min.js" defer="defer"></script> <!-- <script src="./Localize.min.js" defer="defer"></script>
<script src="./ImageAndDetail.min.js" defer="defer"></script> <script src="./ImageAndDetail.min.js" defer="defer"></script>

17632
lang/CardInfo_en.json Normal file

File diff suppressed because it is too large Load diff

16263
lang/CardInfo_ko.json Normal file

File diff suppressed because it is too large Load diff

16232
lang/CardInfo_ru.json Normal file

File diff suppressed because it is too large Load diff

1
lang/CardInfo_zh_CN.json Normal file

File diff suppressed because one or more lines are too long

View file

@ -9,8 +9,10 @@ ImageAndDetail.min.js
webxoss.js webxoss.js
css.css css.css
CardInfo.js CardInfo.js
CardInfo_ru.js lang/CardInfo_en.json
CardInfo_ko.js lang/CardInfo_zh_CN.json
lang/CardInfo_ru.json
lang/CardInfo_ko.json
# DeckEditor # # DeckEditor #
DeckEditor/ DeckEditor/