User:Azure2022/earthquake-list-helper.js

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

/**
 * Code from User:Scarsnevergoaway's tool
 */
 $.when(
	$.ajax("//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js", { dataType: "script", cache: true }),
	$.ajax("//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript", { dataType: "script", cache: true })
).then(function() {
	pathoschild.TemplateScript.add(
		[
			{
				name: "ELH-半自动翻译地震列表",
				tooltip: "半自动翻译",
				script: elh
			},
			
		],

		// common options
		{ forActions: "edit", category: wgULS('半自动翻译地震列表', '半自动翻译地震列表')}
	);
});

/**
 * Add custom extension methods to the TemplateScript editor.
 * @param editor The TemplateScript editor to extend.
 */
 function ohc_extend_editor(editor) {
	editor.ohc_regex = function(rg, sub, func) {
		var text = editor.get();
		text = ohc.dateutil.regex(text, rg, sub, func);
		editor.set(text);

		return editor;
	};
}

var summary = {
    elh: wgULS('Translated by [[User:Azure2022/earthquake-list-helper.js]]', 'Translated by User:Azure2022/earthquake-list-helper.js'),
    
};

function edit_summary(editor, summary) {
	editor
		.options({ minor: true })
		.appendEditSummary(summary)
		.clickDiff();
}

function elh(editor) {
    editor
        .replace(/==\s*Overall\s*==/g, '==总览==')
        .replace(/===\s*By\s+death\s+toll\s*===/g, '===按死者人数===')
        .replace(/===\s*By\s+magnitude\s*===/g, '===按震级===')
        .replace(/===\s*Notable\s+events\s*===/g, '===按月份===')
        .replace(/===\s*January\s*===/g, '===一月===')
        .replace(/===\s*February\s*===/g, '===二月===')
        .replace(/===\s*March\s*===/g, '===三月===')
        .replace(/===\s*April\s*===/g, '===四月===')
        .replace(/===\s*May\s*===/g, '===五月===')
        .replace(/===\s*June\s*===/g, '===六月===')
        .replace(/===\s*July\s*===/g, '===七月===')
        .replace(/===\s*August\s*===/g, '===八月===')
        .replace(/===\s*September\s*===/g, '===九月===')
        .replace(/===\s*October\s*===/g, '===十月===')
        .replace(/===\s*November\s*===/g, '===十一月===')
        .replace(/===\s*December\s*===/g, '===十二月===')
        .replace(/!\s*Depth (km)\s*/g, '!深度(千米)')
        .replace(/\s*Mercalli intensity scale\s*/g, '修订麦加利地震烈度表')
        .replace(/!\s*Location\s*/g, '!位置')
        .replace(/\s*Dead\s*/g, '死')
        .replace(/\s*Injured\s*/g, '伤')
        .replace(/!\s*Rank\s*/g, '!排行')
        .replace(/!\s*Death toll\s*/g, '!死者人数')
        .replace(/\s*Casualties\s*/g, '死伤')
        .replace(/\s*Notes\s*/g, '注释')
        .replace(/!\s*Date\s*/g, '!日期')
        .replace(/\s*Depth unknown.\s*/g, '深度不明')
        .replace(/\s*Country and location\s*/g, '国家及位置')
        .replace(/\s*At least 10 casualties.\s*/g, '至少10人以上伤亡的地震')
        .replace(/\s*At least 7.0 magnitude.\s*/g, '至少7.0级的地震')
        
}

function error(editor) {
    editor
}