近期攻击翻译优化

This commit is contained in:
AshleyLiuuuuu 2021-11-09 18:23:00 +08:00
parent 6fe46f9adb
commit a0c240aae0

View File

@ -25,9 +25,6 @@
'Classified Ads': '分类广告', 'Classified Ads': '分类广告',
'Properties': '房产', 'Properties': '房产',
'City': '城市', 'City': '城市',
'Education':'教育',
'Gym':'健身房',
'Biology Modules':'生物学课程',
}; };
const titleLinksDict = { const titleLinksDict = {
'Personal stats': '个人统计信息', 'Personal stats': '个人统计信息',
@ -38,7 +35,6 @@
'City': '城市', 'City': '城市',
'Back to Estate Agents': '返回地产中介', 'Back to Estate Agents': '返回地产中介',
'Tutorial': '教程', 'Tutorial': '教程',
'Back to Education':'返回',
}; };
const sidebarDict = { // todo 从json加载 const sidebarDict = { // todo 从json加载
'Money': '现金', 'Money': '现金',
@ -160,11 +156,6 @@
'Intelligence': '智力 INT', 'Intelligence': '智力 INT',
'Endurance': '耐心 END', 'Endurance': '耐心 END',
}; };
const attackDict = {
"mugged": "打劫了 ",
"arrested": "逮捕了 ",
"hospitalized": "暴力殴打了 "
};
const newspaperDict = { const newspaperDict = {
'front page': '头版', 'front page': '头版',
'archive': '归档', 'archive': '归档',
@ -258,14 +249,14 @@
'Area': '地区', 'Area': '地区',
}; };
const gymDict={ const gymDict={
'Strength':'力量 STR', 'Strength': '力量 STR',
'STR':'力量 STR', 'STR': '力量 STR',
'TRAIN':'锻炼', 'TRAIN': '锻炼',
'Welcome to':'欢迎来到 ', 'Welcome to': '欢迎来到 ',
'!':'', '!': '',
'You walk into the gym and begin browsing the exercises available.': 'You walk into the gym and begin browsing the exercises available.':
'你走进健身房,开始浏览可用的健身器材。', '你走进健身房,开始浏览可用的健身器材。',
'You have':'你有', 'You have': '你有',
'available to use.': '可用于锻炼。', 'available to use.': '可用于锻炼。',
'energy': '能量', 'energy': '能量',
'Estimated Energy progress:': '(TornTools) 预估健身房解锁进程:', 'Estimated Energy progress:': '(TornTools) 预估健身房解锁进程:',
@ -286,17 +277,6 @@
'Are you sure you would like to buy this membership?': '确定购买这个健身房会员吗?', 'Are you sure you would like to buy this membership?': '确定购买这个健身房会员吗?',
'Not Available': '不可用', 'Not Available': '不可用',
}; };
const eduDict={
'Biology':'生物学',
'Biology Modules':'生物学课程',
'Introduction to Biochemistry':'生物化学概论',
'You do not meet the requirements for this course. Please complete the prerequisites first.':
'你不符合本课程的要求。请先学习前置课程。',
'Description:':'描述:',
'Learning outcomes:':'学习后可获得:',
'Prerequisites:':'前置要求',
'Parameters:':'课程参数',
};
/** /**
@ -442,21 +422,32 @@
if (e.firstChild.nodeValue === 'Latest Events') { if (e.firstChild.nodeValue === 'Latest Events') {
homeEvents = $(e).parent().next().find('span'); homeEvents = $(e).parent().next().find('span');
} else if (e.firstChild.nodeValue === 'Latest Attacks') { } else if (e.firstChild.nodeValue === 'Latest Attacks') {
const attackDict = {
"mugged": "打劫了 ",
"attached": "攻击了 ",
"arrested": "逮捕了 ",
"hospitalized": "暴力殴打了 ",
"but": "但是",
"Someone": "有人",
"lost": "失败了"
}
$(e).parent().next().find('span').each(function () { $(e).parent().next().find('span').each(function () {
let nodes = $(this)[0].childNodes; let nodes = $(this)[0].childNodes;
nodes.forEach((v, i) => { nodes.forEach((v, i) => {
if (v.nodeValue !== null) { if (v.nodeValue !== null) {
let waitToTsf = v.nodeValue.toString().indexOf(" "); let waitToTsf = v.nodeValue.toString().indexOf(" ");
if (waitToTsf >= 0) {
switch (waitToTsf) {
case 0:
$(this)[0].childNodes[i].nodeValue = " " + attackDict[$(this)[0].childNodes[i].nodeValue.split(" ")[1]];
break;
default: let words = v.nodeValue.replace("\n", "").toString().split(" ");
$(this)[0].childNodes[i].nodeValue = "有人" + attackDict[$(this)[0].childNodes[i].nodeValue.split(" ")[1]]; words.forEach((word, j) => {
if (attackDict.hasOwnProperty(word)) {
if (word === "Someone") {
$(this)[0].childNodes[i].nodeValue = $(this)[0].childNodes[i].nodeValue.replace(" ", "");
} }
let change = $(this)[0].childNodes[i].nodeValue.replace(word, attackDict[word]);
$(this)[0].childNodes[i].nodeValue = change;
} }
})
} }
}, this); }, this);
}); });
@ -568,40 +559,33 @@
e.nodeValue=gymDict[e.nodeValue.trim()]; e.nodeValue=gymDict[e.nodeValue.trim()];
}); });
// 4属性标题 // 4属性标题
$('h3[class^="title"]').each((i,e)=>{ $('h3[class^="title"]').each((i, e) => {
if (gymDict[$(e).text().trim()]) if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
}); });
// 4属性的介绍 与冰蛙冲突 // 4属性的介绍 与冰蛙冲突
$('div[class^="description"] p:nth-child(1)').each((i,e)=>{ $('div[class^="description"] p:nth-child(1)').each((i, e) => {
if (gymDict[$(e).text().trim()]) if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
}); });
// 每次锻炼的花销 // 每次锻炼的花销
// $('div[class^="description"] p:nth-child(2)').each((i,e)=>{ $('div[class^="description"] p:nth-child(2)').each((i, e) => {
// const energyPerTrain=$(e).text().split(' ').length===4?$(e).text().split(' ')[0]:null; const energyPerTrain = $(e).text().split(' ').length === 4 ? $(e).text().split(' ')[0] : null;
// if(gymDict[$(e).text().replace(energyPerTrain,`{$}`)]) if (gymDict[$(e).text().replace(energyPerTrain, `{$}`)])
// $(e).text(gymDict[$(e).text().replace(energyPerTrain,`{$}`)].replace(`{$}`,energyPerTrain)); $(e).text(gymDict[$(e).text().replace(energyPerTrain, `{$}`)].replace(`{$}`, energyPerTrain));
// }); });
// 锻炼页面所有按钮 // 锻炼按钮
$('button[class^="button"]').each((i,e)=>{ $('button[class^="button"]').each((i, e) => {
if (gymDict[$(e).text().trim()]) if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
}); });// cancel按钮
// cancel按钮 $('button[class^="cancel"]').each((i, e) => {
$('button[class^="cancel"]').each((i,e)=>{
if (gymDict[$(e).text().trim()]) if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
}); });
// 锻炼的提示信息 // 锻炼的提示信息
$('div[class^="messageWrapper"] p').each((i,e)=>{ $('div[class^="messageWrapper"] p').each((i, e) => {
/** if (gymDict[$(e).text()])
* todo
* <p>You dug deep and completed 15 minutes of incline sprints</p>
* <p role="alert" class="gained___3T_GZ">You gained 1,854.05 speed</p>
*/
//$(e).attr('class').match(/gained/)
if(gymDict[$(e).text()])
$(e).text(gymDict[$(e).text()]); $(e).text(gymDict[$(e).text()]);
}); });
// 健身房信息 标题 // 健身房信息 标题
@ -636,87 +620,6 @@
return; return;
} }
/**
* 教育页面
*/
if (window.location.href.indexOf('education.php') >= 0) {
const eduOB = new MutationObserver(eduOBInit);
function eduOBInit() {
eduOB.disconnect();
eduTrans();
eduOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
}
function eduTrans() {
titleTrans();
contentTitleLinksTrans();
// 大科目、学院标题
$('div.content-wrapper div.title').each((i,e)=>{
if(eduDict[$(e).text().trim()])
e.firstChild.nodeValue=eduDict[$(e).text().trim()];
});
// 学院详情标题
$('div.content-wrapper div.title-black').each((i,e)=>{
if(e.childNodes.length===3)
if(eduDict[e.lastChild.nodeValue.trim()])
e.lastChild.nodeValue=' '+eduDict[e.lastChild.nodeValue.trim()];
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 学院详情 小课程标题
$('div.content-wrapper span.module-name').each((i,e)=>{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 课程详情 7 标题
$('div.module-desc p.title').each((i,e)=>{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 学院详情 小课程提示信息
$('div.content-wrapper div.msg-cont div').each((i,e)=>{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 课程介绍中的所有li元素
$('div.parameters ul.info li').each((i,e)=>{
if(e.childNodes.length===1) {
const spl = $(e).text().trim().split(' ');
switch (spl[0]) {
case 'Length:': {//Length
const d = spl[1].slice(0, -1);
const h = spl[2].slice(0, -1);
const m = spl[3].slice(0, -1);
$(e).text('时长:' + d + '天' + h + '时' + m + '分');
return;
}
case 'Cost:': {//Cost
$(e).text('费用:' + spl[1]);
return;
}
case 'Tier:': {//Tier
$(e).text('级别:' + spl[1]);
return;
}
case 'Gain': {//gain
//$(e).text('级别:' + spl[1]);
return;
}
}
}
else{
console.log(e.children)
}
});
}
eduTrans();
eduOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
return;
}
/** /**
* 报纸菜单 * 报纸菜单
*/ */
@ -1200,10 +1103,10 @@
return; return;
} }
return; return;
;
} }
if ($(e).find('a').text().toLowerCase().indexOf('someone') < 0 && // 避免玩家名带有someone字样 if (spl[0] === 'Someone') { // 被匿名
$(e).text().split(' ')[0].toLowerCase()==='someone') { // 被匿名
if (spl.length === 6 && spl[3] === 'hospitalized') { // 匿名hos if (spl.length === 6 && spl[3] === 'hospitalized') { // 匿名hos
e.firstChild.nodeValue = '有人袭击你并安排你住院 ['; e.firstChild.nodeValue = '有人袭击你并安排你住院 [';
e.childNodes[1].firstChild.nodeValue = '查看'; e.childNodes[1].firstChild.nodeValue = '查看';