更新飞行页面和标题汉化方式

This commit is contained in:
woohoo 2021-11-10 11:59:25 +08:00
parent beae66100e
commit a9dde19476

View File

@ -28,6 +28,7 @@
'Education': '教育', 'Education': '教育',
'Gym': '健身房', 'Gym': '健身房',
'Biology Modules': '生物学课程', 'Biology Modules': '生物学课程',
'Traveling':'飞行中',
}; };
const titleLinksDict = { const titleLinksDict = {
'Personal stats': '个人统计信息', 'Personal stats': '个人统计信息',
@ -39,6 +40,13 @@
'Back to Estate Agents': '返回地产中介', 'Back to Estate Agents': '返回地产中介',
'Tutorial': '教程', 'Tutorial': '教程',
'Back to Education': '返回', 'Back to Education': '返回',
'Recruit Citizens': '招募玩家',
'Events': '通知',
'Travel Home': "回国",
'Rehabilitation': "戒毒康复",
'People': "用户列表",
'Computer': '电脑',
'Market': '市场',
}; };
const sidebarDict = { // todo 从json加载 const sidebarDict = { // todo 从json加载
'Money': '现金', 'Money': '现金',
@ -82,7 +90,7 @@
'Friends': '好友', 'Friends': '好友',
'Enemies': '敌人', 'Enemies': '敌人',
'Information': '信息', 'Information': '信息',
'Areas': '区域', //'Areas': '区域',
'Lists': '列表', 'Lists': '列表',
'messages': '信息', 'messages': '信息',
'events': '通知', 'events': '通知',
@ -188,14 +196,14 @@
'Why not visit our sponsor?': '何不看下赞助广告?', 'Why not visit our sponsor?': '何不看下赞助广告?',
'View all': '查看所有', 'View all': '查看所有',
'Advertise here': '在此刊登广告', 'Advertise here': '在此刊登广告',
'Submit your own comic and earn 250 points!':'提交你创作的漫画赚取250PT', 'Submit your own comic and earn 250 points!': '提交你创作的漫画赚取250PT',
'Welcome to personal page! Who are you seeking?':'欢迎来到交友页面!你想找谁?', 'Welcome to personal page! Who are you seeking?': '欢迎来到交友页面!你想找谁?',
'Search or put up your own ad!':'搜索或刊登你自己的广告!', 'Search or put up your own ad!': '搜索或刊登你自己的广告!',
'Put up your own personal advertisement':'发布你自己的交友广告', 'Put up your own personal advertisement': '发布你自己的交友广告',
'Go to an interview to see if you can get the job, or check out one of the companies that take your fancy, someone might give you the chance of being their employee?': 'Go to an interview to see if you can get the job, or check out one of the companies that take your fancy, someone might give you the chance of being their employee?':
'参加面试,看看你是否能得到这份工作?或者去看看那些让你心动的公司,有人可能会提供你成为他们的员工的机会?', '参加面试,看看你是否能得到这份工作?或者去看看那些让你心动的公司,有人可能会提供你成为他们的员工的机会?',
'To claim the rewards, please click claim and hospitalize the person.':'', 'To claim the rewards, please click claim and hospitalize the person.': '',
'Put a bounty on someone':'', 'Put a bounty on someone': '',
}; };
const propertyDict = { const propertyDict = {
'Shack': '棚屋', 'Shack': '棚屋',
@ -230,30 +238,20 @@
'Upkeep:': '维护费:', 'Upkeep:': '维护费:',
'Staff:': '雇员费用:', 'Staff:': '雇员费用:',
}; };
const travelingDict = { // todo jsonify const travelingDict = {
'Recruit Citizens': '招募玩家', 'Remaining Flight Time -': '剩余时间 - ',
'Events': '事件',
'Torn to London.': '正在飞往英国伦敦London。', 'Torn to London.': '正在飞往英国伦敦London。',
'London to Torn.': '正从英国伦敦London回城。', // todo 所有目的地 'London to Torn.': '正从英国伦敦London回城。',
'\nRemaining Flight Time -\n': ' 剩余时间 - ',
'Travel Home': "回国",
'Rehabilitation': "戒毒康复",
'People': "用户列表",
'Torn to Zurich.': '正在飞往瑞士苏黎世Zurich。', 'Torn to Zurich.': '正在飞往瑞士苏黎世Zurich。',
'Zurich to Torn.': '正从瑞士苏黎世Zurich回城。', 'Zurich to Torn.': '正从瑞士苏黎世Zurich回城。',
}; };
// 界面tips todo 全收集翻译 // 界面tips todo 全收集、翻译
const tipsDict = { const tipsDict = {
'\nAccording to the Economist Intelligence Unit\'s Quality of Life Index, Switzerland is the second best place in the world to be born, after Denmark. Torn ranked 224th, despite there being only 194 recognised nations in the world.\t': "根据经济学人信息部提供的生活质量指数瑞士是世界上第二个最适合出生的地方仅次于丹麦。尽管世界上只有194个公认的国家但托恩却排名第224位。", 'According to the Economist Intelligence Unit\'s Quality of Life Index, Switzerland is the second best place in the world to be born, after Denmark. Torn ranked 224th, despite there being only 194 recognised nations in the world.': "根据经济学人信息部提供的生活质量指数瑞士是世界上第二个最适合出生的地方仅次于丹麦。尽管世界上只有194个公认的国家但托恩却排名第224位。",
'The opportunities for employment in Torn are wide and varied, from jobs in the zoo and the meat warehouse through to fantastic openings at the strip club - a description rarely used to refer to those who work there.': "托恩的就业机会广泛而多样,从动物园和肉类仓库的工作,到脱衣舞俱乐部的奇妙开场--这是一个很少用来形容在那里工作的人的描述。",
'\nThe opportunities for employment in Torn are wide and varied, from jobs in the zoo and the meat warehouse through to fantastic openings at the strip club - a description rarely used to refer to those who work there.\t': 'One of the main requirements for a wedding to take place in Torn is the procurement of a ring. You may either purchase one from the Jewellery Store, or you can choose the more romantic option of stealing one, which requires far more effort if you think about it.': "在托恩举行婚礼的主要要求之一就是购买一枚戒指。你可以从珠宝店购买,也可以选择在偷窃戒指中选择一种很浪漫的方式,但是你冷静下来想想的话,这也是需要付出更大代价的。",
"托恩的就业机会广泛而多样,从动物园和肉类仓库的工作,到脱衣舞俱乐部的奇妙开场--这是一个很少用来形容在那里工作的人的描述。", "Despite having no discernible court system Torn still employs several thousand people within its Judicial Services department. Nobody knows what the hell these people do all day, but if we had to guess, we'd say Solitaire.": "尽管没有明显的法院系统,托恩仍然在其司法服务部门雇用了几千人。没有人知道这些人整天都在做什么,但如果我们必须猜测,我们会说是接龙。",
"At one point a Dual Wield Melee course was available at Torn City College for a fee of $50,000,000, but this was discontinued when Torn's citizens realized they were effectively paying to learn how to hold two things at once.": "托恩城市学院一度开设了双持近战课程收费50,000,000美元但当托恩的市民意识到他们实际上是在花钱学习如何同时持有两样东西时这个课程就停止了。"
'\nOne of the main requirements for a wedding to take place in Torn is the procurement of a ring. You may either purchase one from the Jewellery Store, or you can choose the more romantic option of stealing one, which requires far more effort if you think about it.\t': "在托恩举行婚礼的主要要求之一就是购买一枚戒指。你可以从珠宝店购买,也可以选择在偷窃戒指中选择一种很浪漫的方式,但是你冷静下来想想的话,这也是需要付出更大代价的。",
"\nDespite having no discernible court system Torn still employs several thousand people within its Judicial Services department. Nobody knows what the hell these people do all day, but if we had to guess, we'd say Solitaire.\t": "尽管没有明显的法院系统,托恩仍然在其司法服务部门雇用了几千人。没有人知道这些人整天都在做什么,但如果我们必须猜测,我们会说是接龙。",
"\nAt one point a Dual Wield Melee course was available at Torn City College for a fee of $50,000,000, but this was discontinued when Torn's citizens realized they were effectively paying to learn how to hold two things at once.\t": "托恩城市学院一度开设了双持近战课程收费50,000,000美元但当托恩的市民意识到他们实际上是在花钱学习如何同时持有两样东西时这个课程就停止了。"
}; };
const cityDict = {//todo const cityDict = {//todo
'Map': '地图', 'Map': '地图',
@ -289,7 +287,7 @@
'Chance of hitting opponent': '击中对手的概率', 'Chance of hitting opponent': '击中对手的概率',
"Ability to withstand damage": "承受伤害的能力", "Ability to withstand damage": "承受伤害的能力",
"Damage you make on impact": "攻击造成的伤害", "Damage you make on impact": "攻击造成的伤害",
'Ability to evade an attack':'躲避攻击的能力', 'Ability to evade an attack': '躲避攻击的能力',
'{$} energy per train': '每次锻炼花费{$}能量', '{$} energy per train': '每次锻炼花费{$}能量',
'Class:': '健身房类别:', 'Class:': '健身房类别:',
'Heavyweight': '重型', 'Heavyweight': '重型',
@ -315,15 +313,15 @@
'intelligence': '智力(INT)', 'intelligence': '智力(INT)',
'endurance': '耐心(END)', 'endurance': '耐心(END)',
'manual labor': '体力(MAN)', 'manual labor': '体力(MAN)',
'[Leave this course]':'[退出课程]', '[Leave this course]': '[退出课程]',
'You are taking the':'你正在学习', 'You are taking the': '你正在学习',
'education course.':'课程', 'education course.': '课程',
'This course will be completed in':'该课程将完成于', 'This course will be completed in': '该课程将完成于',
'Strength and Conditioning':'力量和体能训练', 'Strength and Conditioning': '力量和体能训练',
'[Leave course]':'[确认退出课程]', '[Leave course]': '[确认退出课程]',
'Are you sure you want to leave the':'你确定你要退出', 'Are you sure you want to leave the': '你确定你要退出',
'course?':'课程吗?', 'course?': '课程吗?',
'The current progress will be canceled and you\'ll have to start all over again.':'目前的进度将被取消,你将需要重新开始。', 'The current progress will be canceled and you\'ll have to start all over again.': '目前的进度将被取消,你将需要重新开始。',
}; };
@ -331,47 +329,38 @@
* 飞行页面 * 飞行页面
*/ */
if (window.location.href.indexOf('index.php') >= 0 && if (window.location.href.indexOf('index.php') >= 0 &&
$('.travelling h4').length !== 0) { $('div.travelling h4').length !== 0) {
titleTrans(); const travelOB = new MutationObserver(travelOBInit);
//如果在飞行页面 function travelOBInit() {
if ($('span.remaining-time').length !== 0) { travelOB.disconnect();
$('#skip-to-content')[0].firstChild.nodeValue = '飞行中'; travelTrans();
travelOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
}
// 气泡 需要判断是否存在 因为torntools默认关闭云和飞机 冰蛙也会关闭 function travelTrans() {
if ($('div.inner-popup').length !== 0 && tipsDict[$('div.inner-popup')[0].textContent]) { titleTrans();
$('div.inner-popup')[0].textContent = tipsDict[$('div.inner-popup')[0].textContent]; contentTitleLinksTrans();
}
// 气泡
if (travelingDict[$('div.inner-popup').text().trim()])
$('div.inner-popup').text(travelingDict[$('div.inner-popup').text().trim()]);
// Remaining Flight Time - // Remaining Flight Time -
if (travelingDict[$('span.remaining-time')[0].firstChild.nodeValue]) { $('div.destination-title span').contents().each((i, e) => {
$('span.remaining-time')[0].firstChild.nodeValue = travelingDict[$('span.remaining-time')[0].firstChild.nodeValue]; if (e.childNodes.length !== 0) return;
if (!e.nodeValue) return;
if (travelingDict[e.nodeValue.trim()])
e.nodeValue = travelingDict[e.nodeValue.trim()];
});
// torntools扩展插件落地时间
if($('div.tt-landing-time span.description').text().split(' ')[0]==='Landing'){
const landingTime=$('div.tt-landing-time span.description').text().slice(11,19);
$('div.tt-landing-time span.description').text('于 '+landingTime+' 降落');
} }
$("#recruit-citizens")[0].firstChild.nodeValue = travelingDict[$("#recruit-citizens")[0].firstChild.nodeValue];
} }
//Events travelTrans();
$("#events")[0].firstChild.nodeValue = travelingDict[$("#events")[0].firstChild.nodeValue] travelOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
if ($("#travel-home").length !== 0) {
$("#travel-home")[0].firstChild.nodeValue = travelingDict[$("#travel-home")[0].firstChild.nodeValue];
$("#rehab")[0].firstChild.nodeValue = travelingDict[$("#rehab")[0].firstChild.nodeValue];//todo 在瑞士就加rehab
$("#people")[0].firstChild.nodeValue = travelingDict[$("#people")[0].firstChild.nodeValue];
}
const remainingTime = new MutationObserver(mutations => {
if (!travelingDict[$('span.description')[0].firstChild.nodeValue]) return;
remainingTime.disconnect();
/**
* Torn to {dest}.
* <span class="description">Torn to Zurich.</span>
*/
$('span.description')[0].firstChild.nodeValue = travelingDict[$('span.description')[0].firstChild.nodeValue];
remainingTime.observe($('span.remaining-time')[0], {childList: true, subtree: true});
});
remainingTime.observe($('span.remaining-time')[0], {childList: true, subtree: true});
return; return;
} }
@ -694,16 +683,15 @@
}); });
// 教育主页提示内容 // 教育主页提示内容
$('#info_wrapper div.msg').find('*').contents().each((i, e) => { $('#info_wrapper div.msg').find('*').contents().each((i, e) => {
if(e.nodeValue===null) return; if (e.nodeValue === null) return;
if(eduDict[e.nodeValue.trim()]) { if (eduDict[e.nodeValue.trim()]) {
e.nodeValue = eduDict[e.nodeValue.trim()]; e.nodeValue = eduDict[e.nodeValue.trim()];
} } else if (e.nodeValue.indexOf('seconds') >= 0) {
else if(e.nodeValue.indexOf('seconds')>=0){ e.nodeValue = e.nodeValue
e.nodeValue=e.nodeValue .replace(' days, ', '天')
.replace(' days, ','天') .replace(' hours, ', '时')
.replace(' hours, ','时') .replace(' minutes and ', '分')
.replace(' minutes and ','分') .replace(' seconds', '秒');
.replace(' seconds','秒');
} }
}); });
// 学院详情标题 // 学院详情标题
@ -813,20 +801,20 @@
if (date.format('yyyy') !== 'NaN') if (date.format('yyyy') !== 'NaN')
$('span.date-label').text(date.format('yyyy年MM月dd日')); $('span.date-label').text(date.format('yyyy年MM月dd日'));
// 菜单下的信息 工作 壁纸 广告 悬赏 // 菜单下的信息 工作 壁纸 广告 悬赏
$('div.help-message').find('*').contents().each((i,e)=>{ $('div.help-message').find('*').contents().each((i, e) => {
if(!e.nodeValue || e.nodeValue.trim()==='') return; if (!e.nodeValue || e.nodeValue.trim() === '') return;
console.log(e.nodeValue); console.log(e.nodeValue);
if (newspaperDict[e.nodeValue.trim()]) if (newspaperDict[e.nodeValue.trim()])
e.nodeValue = newspaperDict[e.nodeValue.trim()]; e.nodeValue = newspaperDict[e.nodeValue.trim()];
}); });
// 交友 // 交友
$('div.personals-wrap span.msg').find('*').contents().each((i,e)=>{ $('div.personals-wrap span.msg').find('*').contents().each((i, e) => {
if(!e.nodeValue || e.nodeValue.trim()==='') return; if (!e.nodeValue || e.nodeValue.trim() === '') return;
if (newspaperDict[e.nodeValue.trim()]) if (newspaperDict[e.nodeValue.trim()])
e.nodeValue = newspaperDict[e.nodeValue.trim()]; e.nodeValue = newspaperDict[e.nodeValue.trim()];
}); });
// 漫画 // 漫画
if(newspaperDict[$('div.bonus-wrap a').text().trim()]) if (newspaperDict[$('div.bonus-wrap a').text().trim()])
$('div.bonus-wrap a').text(newspaperDict[$('div.bonus-wrap a').text().trim()]); $('div.bonus-wrap a').text(newspaperDict[$('div.bonus-wrap a').text().trim()]);
// 右边栏 // 右边栏
$('div[class^="sideCont"] [class^="title"]').contents().each((i, e) => { $('div[class^="sideCont"] [class^="title"]').contents().each((i, e) => {
@ -1537,9 +1525,10 @@
* 页标题翻译 * 页标题翻译
*/ */
function titleTrans() { function titleTrans() {
if ($('h4#skip-to-content').length === 1) const title = titleDict[$('h4#skip-to-content').text().trim()];
if (titleDict[$('h4#skip-to-content').text().trim()]) //if ($('h4#skip-to-content').length === 1)
$('h4#skip-to-content').text(titleDict[$('h4#skip-to-content').text().trim()]); if (title && $('h4#skip-to-content').css('display')!=='none')
$('h4#skip-to-content').css('display', 'none').after(`<span style='float:left'><h4>` + title + `</h4></span>`);
} }
}()); }());