增加聊天框翻译

This commit is contained in:
woohoo 2021-11-12 17:25:47 +08:00
parent d1a61a7076
commit 2b14ad1af1

View File

@ -560,6 +560,53 @@
const chatDict = { const chatDict = {
'Global': '世界', 'Global': '世界',
'Faction': '帮派', 'Faction': '帮派',
'People': '联系人',
'Settings': '设置',
'Trade': '交易',
'Jail': '监狱',
'Hospital': '医院',
'Company': '公司',
'Height': '高度',
'Width': '宽度',
'Jail & Hospital': '监狱和医院',
'Traveling': '海外',
'Competition': '活动',
'Private': '私聊',
'Room sound': '音效',
'Who is allowed to initiate chat with you?': '谁可以主动与你聊天?',
'Disabled': '关闭',
'Enabled': '开启',
'Flash notifier': '闪烁提示',
'Chirp 1': '啁啾声 1',
'Chirp 2': '啁啾声 2',
'Chirp 3': '啁啾声 3',
'Flash & sound': '闪烁和音效',
'Click 1': '点击音 1',
'Click 2': '点击音 2',
'Data 1': '哒嗒 1',
'Data 2': '哒嗒 2',
'Data 3': '哒嗒 3',
'Double 2':'',
'Electronic 1':'',
'Electronic 2':'',
'Future 1':'',
'Future 2':'',
'Plink 1':'',
'Plink 2':'',
'Soft beep 1':'',
'Soft beep 2':'',
'Subtle':'',
'Transmission 1':'',
'Transmission 2':'',
'Warble 1':'',
'Warble 2':'',
'Only people you know or have met':'只有你认识或遇到过的人',
'Anyone can initiate chat with you':'任何人都可以主动与你聊天',
'Recent':'最近',
'Friends':'好友',
'Blocked':'拉黑',
'All':'全部',
'Enter a name or ID to add to this list':'输入用户名或ID来添加到这个列表',
}; };
/** /**
@ -738,7 +785,7 @@
const chatOB = new MutationObserver(_ => { const chatOB = new MutationObserver(_ => {
chatOB.disconnect(); chatOB.disconnect();
chatTrans(); chatTrans();
chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true}); chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true, attributes: true});
}); });
const chatTrans = function chatTrans() { const chatTrans = function chatTrans() {
// 聊天框的标题 // 聊天框的标题
@ -746,9 +793,47 @@
if (chatDict[$(e).text().trim()]) if (chatDict[$(e).text().trim()])
$(e).text(chatDict[$(e).text().trim()]); $(e).text(chatDict[$(e).text().trim()]);
}); });
// 聊天设置的左边label
$('div[class^="chat-settings-opts"] div[class*="label"]').each((i,e)=>{
if($(e).next().children('div.rc-slider').length>0) {
// 高度和宽度有响应式的%
if (chatDict[$(e).text().split(' ')[0]]) {
$(e).text($(e).text().replace($(e).text().split(' ')[0], chatDict[$(e).text().split(' ')[0]]));
}
return;
}
if (chatDict[$(e).text().trim()])
$(e).text(chatDict[$(e).text().trim()]);
});
// 选项下拉栏
$('div[class^="dropdown-root"]').find('*').contents().each((i,e)=>{
if(e.nodeType!==3) return;
if (chatDict[e.nodeValue])
e.nodeValue=chatDict[e.nodeValue];
});
// 设置的两个选项
$('label[class^="privacy-label"]').each((i,e)=>{
if (chatDict[$(e).text().trim()])
$(e).text(chatDict[$(e).text().trim()]);
});
// people中的5个分类 faction friend...
$('ul[class^="type-list"] li a').each((i,e)=>{
if (chatDict[$(e).text().trim()])
$(e).text(chatDict[$(e).text().trim()]);
});
// people中的列表添加框placeholder
$('div.ac-wrapper input.ac-search').each((i,e)=>{
if (chatDict[$(e).attr('placeholder')])
$(e).attr('placeholder',chatDict[$(e).attr('placeholder')]);
});
// people中的列表添加框点击后的4个按钮
$('div.ac-wrapper li a').each((i,e)=>{
if (chatDict[$(e).text().trim()])
$(e).text(chatDict[$(e).text().trim()]);
});
}; };
chatTrans(); chatTrans();
chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true}); chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true, attributes: true});
} }
/** /**
@ -1929,7 +2014,8 @@
* 页标题按钮content-title-links * 页标题按钮content-title-links
*/ */
function contentTitleLinksTrans() { function contentTitleLinksTrans() {
$('div.content-title-links a span:nth-child(2)').each((i, e) => { // $('div.content-title-links a span:nth-child(2)').each((i, e) => {
$('div.content-title span:nth-child(2)').each((i, e) => {
if (titleLinksDict[$(e).text()]) if (titleLinksDict[$(e).text()])
$(e).text(titleLinksDict[$(e).text()]); $(e).text(titleLinksDict[$(e).text()]);
else if ($(e).attr('id') === 'events') else if ($(e).attr('id') === 'events')