diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 5c6fad1..acd640d 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -16,6 +16,26 @@ ___win_WHTRANS.WHTRANS = true; const $ = window.jQuery; + const titleDict = { + 'Home': '主页', + 'Estate Agents': '地产中介', + 'Newspaper': '报纸', + 'Job Listing': '工作列表', + 'Freebies': '赠品', + 'Classified Ads': '分类广告', + 'Properties': '房产', + 'City': '城市', + }; + const titleLinksDict = { + 'Personal stats': '个人统计信息', + 'Log': '日志', + 'Tell your story': '说出你的故事', + 'Rental Market': '租赁市场', + 'Selling Market': '销售市场', + 'City': '城市', + 'Back to Estate Agents': '返回地产中介', + 'Tutorial': '教程', + }; const sidebarDict = { // todo 从json加载 'Money': '现金', 'Level': '等级', @@ -136,16 +156,6 @@ 'Intelligence': '智力 INT', 'Endurance': '耐心 END', }; - const titleLinksDict = { - 'Personal stats': '个人统计信息', - 'Log': '日志', - 'Tell your story': '说出你的故事', - 'Rental Market': '租赁市场', - 'Selling Market': '销售市场', - 'City': '城市', - 'Back to Estate Agents': '返回地产中介', - 'Tutorial': '教程', - }; const newspaperDict = { 'front page': '头版', 'archive': '归档', @@ -153,28 +163,21 @@ 'properties': '房产', 'freebies': '赠品', 'classified ads': '广告', - 'personals': '情感', + 'personals': '交友', 'bounties': '悬赏', 'comics': '漫画', 'chronicles': '纪事档案馆', - 'TCSE Market Index':'TCSE 股票指数', - 'Weekly bazaars':'每周小店', - 'LOTTERY':'幸运彩票', - 'BOUNTIES':'精选悬赏', - 'TC PERSONALS':'托恩情感', - 'Why not visit our sponsor?':'为什么不访问我们的赞助商呢?', - 'View all':'查看所有', - 'Advertise here':'在此刊登广告', - }; - const titleDict = { - 'Home': '主页', - 'Estate Agents': '地产中介', - 'Newspaper':'报纸', - 'Job Listing':'工作列表', - 'Freebies':'赠品', - 'Classified Ads':'分类广告', + 'TCSE Market Index': 'TCSE 股票指数', + 'Weekly bazaars': '每周小店', + 'LOTTERY': '幸运彩票', + 'BOUNTIES': '精选悬赏', + 'TC PERSONALS': '托恩交友', + 'Why not visit our sponsor?': '为什么不访问我们的赞助商呢?', + 'View all': '查看所有', + 'Advertise here': '在此刊登广告', }; const propertyDict = { + 'Shack': '棚屋', 'Trailer': '拖车', 'Apartment': '公寓', 'Semi - Detached': '半独立式住宅', @@ -197,11 +200,14 @@ 'Cost:': '花费:', 'Cost per Day': '平均日花费', 'Rental Period': '租期', + 'Rental period:': '租期', 'Rent': '租赁', 'Info': '信息', 'Buy': '购买', 'Property:': '房屋:', 'Modifications': '改造设施', + 'Upkeep:': '维护费:', + 'Staff:': '雇员费用:', }; const travelingDict = { // todo jsonify 'Recruit Citizens': '招募玩家', @@ -228,6 +234,20 @@ "\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 + 'Map': '地图', + 'Quick Links': '快速链接', + 'Key of Symbols': '标志建筑', + 'Financial': '金融', + 'Administrative': '行政', + 'inactive-mode1': '地图上只显示你的帮派的和临近的地盘。', + 'inactive-mode2': '启用【全地盘视图】将下载完整地图,大约2.75mb。', + 'active-mode': '【全地盘视图】已启用。', + 'ADMINISTRATIVE': '行政', + 'City Hall': '市政厅', + 'Sort by:': '分类排序方式:', + 'Area': '地区', + }; /** @@ -369,6 +389,7 @@ if (window.location.href.indexOf('index.php') >= 0 && $('h4#skip-to-content').text().indexOf('Home') >= 0) { titleTrans(); + contentTitleLinksTrans(); let homeEvents = null; @@ -408,12 +429,81 @@ $(e).text(homeDict[$(e).text()]); }); - contentTitleLinksTrans(); eventsTrans(homeEvents); return; } + /** + * city + */ + if (window.location.href.indexOf('city.php') >= 0) { + const cityOB = new MutationObserver(cityOBInit); + + function cityOBInit() { + cityOB.disconnect(); + cityTrans(); + cityOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + } + + function cityTrans() { + titleTrans(); + contentTitleLinksTrans(); + + // Map or Quick Links + $('a.ui-tabs-anchor span').each((i, e) => { + if (cityDict[$(e).text()]) + $(e).text(cityDict[$(e).text()]); + }); + + // 标志建筑 标题 + if (cityDict[$('div.title-black').text()]) + $('div.title-black').text(cityDict[$('div.title-black').text()]); + // 标志建筑 6个分类 + $('ul.map-symbols span').each((i, e) => { + if (cityDict[$(e).text()]) + $(e).text(cityDict[$(e).text()]); + }); + + // 地图显示模式 + // 不完全显示 文字 + $('span.inactive-mode').html(cityDict['inactive-mode1'] + `
` + cityDict['inactive-mode2']); + // 完全显示 文字 + $('span.active-mode').text(cityDict['active-mode']); + // 开关 + $('div.on-label').text('已开启'); + $('div.off-label').text('已关闭'); + + // 快速链接中的分类标题 + $('li.title').each((i, e) => { + if (cityDict[$(e).text()]) + $(e).text(cityDict[$(e).text()]); + }); + + // 快速链接中的区域 + $('li a[class^="font-num-"] span').each((i, e) => { + if (cityDict[$(e).text()]) + $(e).text(cityDict[$(e).text()]); + }); + + // 快速链接中的分类选择 + $('div.sort-by label.marker-css').each((i, e) => { + if (cityDict[$(e).text()]) + $(e).text(cityDict[$(e).text()]); + }); + + // 快速链接中的sort by + $('span#wai-sort-by').each((i, e) => { + if (cityDict[$(e).text()]) + $(e).text(cityDict[$(e).text()]); + }); + } + + cityTrans(); + cityOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + return; + } + /** * 报纸菜单 */ @@ -422,12 +512,14 @@ window.location.href.indexOf('personals.php') >= 0 || window.location.href.indexOf('bounties.php') >= 0 || window.location.href.indexOf('comics.php') >= 0) { const newspaperOB = new MutationObserver(newspaperOBInit); - function newspaperOBInit(){ + + function newspaperOBInit() { newspaperOB.disconnect(); newspaperTrans(); newspaperOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); } - function newspaperTrans(){ + + function newspaperTrans() { titleTrans(); contentTitleLinksTrans(); if ($('a.newspaper-link').length === 0) return; @@ -440,25 +532,27 @@ $('div.price.left').contents()[2].nodeValue = '文章翻译请关注中文公众号Torncity'; // 日期翻译 const date = new Date($('span.date-label').text()); - if(date.format('yyyy')!=='NaN') + if (date.format('yyyy') !== 'NaN') $('span.date-label').text(date.format('yyyy年MM月dd日')); // 右边栏 $('div[class^="sideCont"] [class^="title"]').contents().each((i, e) => { - if(newspaperDict[e.nodeValue]) - e.nodeValue=newspaperDict[e.nodeValue]; + if (newspaperDict[e.nodeValue]) + e.nodeValue = newspaperDict[e.nodeValue]; }); // 彩票信息 - $('span[class^="winner"]').each((i,e)=>{}); + $('span[class^="winner"]').each((i, e) => { + }); // 底部链接 // Why not visit our sponsor? - if(newspaperDict[$('div.link-left').text().trim()]) + if (newspaperDict[$('div.link-left').text().trim()]) $('div.link-left').text(newspaperDict[$('div.link-left').text().trim()]); // View all | Advertise here - $('div.link-right a').contents().each((i,e)=>{ - if(newspaperDict[e.nodeValue.trim()]) - e.nodeValue=newspaperDict[e.nodeValue.trim()]; + $('div.link-right a').contents().each((i, e) => { + if (newspaperDict[e.nodeValue.trim()]) + e.nodeValue = newspaperDict[e.nodeValue.trim()]; }) } + newspaperTrans(); newspaperOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); return; @@ -544,8 +638,7 @@ // 房屋详情表格 $('div.info-block span.bold').each((i, e) => { - // 2 6 10 14 18 22 26 30 ... - if (i % 4 === 2) { + if (e.childElementCount === 2) { /** * On @@ -563,6 +656,10 @@ e.firstChild.nodeValue = propertyDict[e.firstChild.nodeValue.trim()]; } }); + $('div.rental-period span.bold').each((i, e) => { + if (propertyDict[e.firstChild.nodeValue.trim()]) + e.firstChild.nodeValue = propertyDict[e.firstChild.nodeValue.trim()]; + }); // 窄边 cost happy $('span.title-laptop.bold').each((i, e) => { if (propertyDict[$(e).text().trim()])