适配机库升级包

This commit is contained in:
xkeyC 2023-10-14 23:47:15 +08:00
parent 974f196869
commit d5d02d933a
4 changed files with 46 additions and 16 deletions

View File

@ -144,14 +144,29 @@ function GetSCLocalizationTranslateString(txtSrc) {
} else if (SCLocalizationEnableSplitMode) { } else if (SCLocalizationEnableSplitMode) {
if (sourceKey.includes(" - ")) { if (sourceKey.includes(" - ")) {
let nodeValue = txtSrc let nodeValue = txtSrc
sourceKey.split(" - ").forEach(function (splitKey) { let splitKey = sourceKey.split(" - ");
if (SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()]) { if (splitKey[0].toLowerCase() === "upgrade" && key.includes("to") && key.endsWith("edition")) {
nodeValue = nodeValue.replace(splitKey, SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()]) // 升级包规则
let noVersionStr = key.replace("STANDARD EDITION".toLowerCase(), "").replace("upgrade", "").replace("WARBOND EDITION".toLowerCase(), "")
let shipNames = noVersionStr.split(" to ")
let finalString = "升级包 " + GetSCLocalizationTranslateString(shipNames[0]) + " 到 " + GetSCLocalizationTranslateString(shipNames[1]);
if (key.endsWith("WARBOND EDITION".toLowerCase())) {
finalString = finalString + " 战争债券版"
} else { } else {
nodeValue = nodeValue.replace(splitKey, GetSCLocalizationTranslateString(splitKey)) finalString = finalString + " 标准版"
} }
}); txtSrc = finalString
txtSrc = nodeValue } else {
// 机库通用规则
splitKey.forEach(function (splitKey) {
if (SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()]) {
nodeValue = nodeValue.replace(splitKey, SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()])
} else {
nodeValue = nodeValue.replace(splitKey, GetSCLocalizationTranslateString(splitKey))
}
});
txtSrc = nodeValue
}
} else if (key.endsWith("starter pack") || key.endsWith("starter package")) { } else if (key.endsWith("starter pack") || key.endsWith("starter package")) {
let shipName = key.replace("starter package", "").replace("starter pack", "").trim() let shipName = key.replace("starter package", "").replace("starter pack", "").trim()
if (SCLocalizationReplaceLocalesMap[shipName.toLowerCase()]) { if (SCLocalizationReplaceLocalesMap[shipName.toLowerCase()]) {
@ -161,7 +176,7 @@ function GetSCLocalizationTranslateString(txtSrc) {
} else if (key.startsWith("the ") && SCLocalizationReplaceLocalesMap[noTheKey]) { } else if (key.startsWith("the ") && SCLocalizationReplaceLocalesMap[noTheKey]) {
txtSrc = SCLocalizationReplaceLocalesMap[noTheKey]; txtSrc = SCLocalizationReplaceLocalesMap[noTheKey];
} else if (key.startsWith("- ") && SCLocalizationReplaceLocalesMap[noHorizontalKey]) { } else if (key.startsWith("- ") && SCLocalizationReplaceLocalesMap[noHorizontalKey]) {
txtSrc = "- "+SCLocalizationReplaceLocalesMap[noHorizontalKey]; txtSrc = "- " + SCLocalizationReplaceLocalesMap[noHorizontalKey];
} }
} }
return txtSrc return txtSrc

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "星际公民盒子浏览器拓展", "name": "星际公民盒子浏览器拓展",
"version": "0.0.3", "version": "0.0.4",
"description": "为星际公民网站及工具站提供汉化", "description": "为星际公民网站及工具站提供汉化",
"author": "xkeyC", "author": "xkeyC",
"icons": { "icons": {

View File

@ -144,14 +144,29 @@ function GetSCLocalizationTranslateString(txtSrc) {
} else if (SCLocalizationEnableSplitMode) { } else if (SCLocalizationEnableSplitMode) {
if (sourceKey.includes(" - ")) { if (sourceKey.includes(" - ")) {
let nodeValue = txtSrc let nodeValue = txtSrc
sourceKey.split(" - ").forEach(function (splitKey) { let splitKey = sourceKey.split(" - ");
if (SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()]) { if (splitKey[0].toLowerCase() === "upgrade" && key.includes("to") && key.endsWith("edition")) {
nodeValue = nodeValue.replace(splitKey, SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()]) // 升级包规则
let noVersionStr = key.replace("STANDARD EDITION".toLowerCase(), "").replace("upgrade", "").replace("WARBOND EDITION".toLowerCase(), "")
let shipNames = noVersionStr.split(" to ")
let finalString = "升级包 " + GetSCLocalizationTranslateString(shipNames[0]) + " 到 " + GetSCLocalizationTranslateString(shipNames[1]);
if (key.endsWith("WARBOND EDITION".toLowerCase())) {
finalString = finalString + " 战争债券版"
} else { } else {
nodeValue = nodeValue.replace(splitKey, GetSCLocalizationTranslateString(splitKey)) finalString = finalString + " 标准版"
} }
}); txtSrc = finalString
txtSrc = nodeValue } else {
// 机库通用规则
splitKey.forEach(function (splitKey) {
if (SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()]) {
nodeValue = nodeValue.replace(splitKey, SCLocalizationReplaceLocalesMap[splitKey.toLowerCase()])
} else {
nodeValue = nodeValue.replace(splitKey, GetSCLocalizationTranslateString(splitKey))
}
});
txtSrc = nodeValue
}
} else if (key.endsWith("starter pack") || key.endsWith("starter package")) { } else if (key.endsWith("starter pack") || key.endsWith("starter package")) {
let shipName = key.replace("starter package", "").replace("starter pack", "").trim() let shipName = key.replace("starter package", "").replace("starter pack", "").trim()
if (SCLocalizationReplaceLocalesMap[shipName.toLowerCase()]) { if (SCLocalizationReplaceLocalesMap[shipName.toLowerCase()]) {
@ -161,7 +176,7 @@ function GetSCLocalizationTranslateString(txtSrc) {
} else if (key.startsWith("the ") && SCLocalizationReplaceLocalesMap[noTheKey]) { } else if (key.startsWith("the ") && SCLocalizationReplaceLocalesMap[noTheKey]) {
txtSrc = SCLocalizationReplaceLocalesMap[noTheKey]; txtSrc = SCLocalizationReplaceLocalesMap[noTheKey];
} else if (key.startsWith("- ") && SCLocalizationReplaceLocalesMap[noHorizontalKey]) { } else if (key.startsWith("- ") && SCLocalizationReplaceLocalesMap[noHorizontalKey]) {
txtSrc = "- "+SCLocalizationReplaceLocalesMap[noHorizontalKey]; txtSrc = "- " + SCLocalizationReplaceLocalesMap[noHorizontalKey];
} }
} }
return txtSrc return txtSrc

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "星际公民盒子浏览器拓展", "name": "星际公民盒子浏览器拓展",
"version": "0.0.3", "version": "0.0.4",
"description": "为星际公民网站及工具站提供汉化", "description": "为星际公民网站及工具站提供汉化",
"author": "xkeyC", "author": "xkeyC",
"icons": { "icons": {