xkeyC 2024-10-07 11:24:56 +08:00
parent 2a940b9312
commit 495dfd2c94
2 changed files with 7 additions and 9 deletions

View File

@ -197,8 +197,6 @@ function GetSCLocalizationTranslateString(txtSrc) {
return txtSrc
}
InitWebLocalization();
function ReportUnTranslate(k, v) {
if (enable_webview_localization_capture) {

View File

@ -71,12 +71,7 @@ class WebViewModel {
dPrint("webview Navigating url === $url");
if (url.contains("robertsspaceindustries.com")) {
// SC
dPrint("load script");
await Future.delayed(const Duration(milliseconds: 100));
await webview.evaluateJavaScript(localizationScript);
dPrint("update replaceWords");
final replaceWords = _getLocalizationResource("zh-CN");
const org = "https://robertsspaceindustries.com/orgs";
const citizens = "https://robertsspaceindustries.com/citizens";
const organization =
@ -90,13 +85,16 @@ class WebViewModel {
const hangar = "https://robertsspaceindustries.com/account/pledges";
const spectrum =
"https://robertsspaceindustries.com/spectrum/community/";
const spectrum = "https://robertsspaceindustries.com/spectrum";
// https://github.com/StarCitizenToolBox/StarCitizenBoxBrowserEx/issues/1
if (url.startsWith(spectrum)) {
return;
}
dPrint("load script");
await Future.delayed(const Duration(milliseconds: 100));
await webview.evaluateJavaScript(localizationScript);
if (url.startsWith(org) ||
url.startsWith(citizens) ||
url.startsWith(organization)) {
@ -144,7 +142,9 @@ class WebViewModel {
_curReplaceWords?[element["word"] ?? ""] =
element["replacement"] ?? "";
}
await webview.evaluateJavaScript("InitWebLocalization()");
await Future.delayed(const Duration(milliseconds: 100));
dPrint("update replaceWords");
await webview.evaluateJavaScript(
"WebLocalizationUpdateReplaceWords(${json.encode(replaceWords)},$enableCapture)");