mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-27 00:51:55 +08:00
fix(i18n): 修复首选语言回退并准备 v1.0.8
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import XCTest
|
||||
@testable import PaopaoLocationSpoofer
|
||||
|
||||
final class AppLocalizationTests: XCTestCase {
|
||||
func testOnlyFirstPreferredLanguageSelectsTheAppLanguage() {
|
||||
XCTAssertEqual(AppLocalization.identifier(for: ["it-IT", "zh-Hans-CN"]), "en")
|
||||
XCTAssertEqual(AppLocalization.identifier(for: ["fr-FR", "zh-Hant-TW"]), "en")
|
||||
XCTAssertEqual(AppLocalization.identifier(for: ["zh-Hans-CN", "it-IT"]), "zh-Hans")
|
||||
XCTAssertEqual(AppLocalization.identifier(for: ["zh-Hant-TW", "en-US"]), "zh-Hant")
|
||||
XCTAssertEqual(AppLocalization.identifier(for: []), "en")
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ final class AppRemoteConfigurationTests: XCTestCase {
|
||||
func testFallbackMatchesCurrentProjectPolicy() {
|
||||
let configuration = AppRemoteConfiguration.fallback
|
||||
|
||||
XCTAssertEqual(configuration.latestVersion, "1.0.7")
|
||||
XCTAssertEqual(configuration.latestVersion, "1.0.8")
|
||||
XCTAssertEqual(configuration.minimumSupportedVersion, "1.0.0")
|
||||
XCTAssertFalse(configuration.requestsCommunityPrompt(for: .shadowrocket))
|
||||
for client in ThirdPartyProxyClient.allCases where client != .shadowrocket {
|
||||
|
||||
@@ -139,7 +139,7 @@ final class ThirdPartyProxyManagerTests: XCTestCase {
|
||||
XCTAssertNil(ThirdPartyProxyClient.shadowrocket.verificationText)
|
||||
XCTAssertEqual(
|
||||
ThirdPartyProxyClient.surge.verificationText,
|
||||
String(localized: "配置已提供,尚未验证")
|
||||
AppLocalization.string("配置已提供,尚未验证")
|
||||
)
|
||||
XCTAssertEqual(ThirdPartyProxyClient.egern.subscriptionURL, ThirdPartyProxyClient.surge.subscriptionURL)
|
||||
XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasPrefix(
|
||||
|
||||
@@ -31,6 +31,8 @@ RUBY
|
||||
|
||||
for key in \
|
||||
'环境信息' \
|
||||
'复制 %@' \
|
||||
'已复制 %@' \
|
||||
'诊断日志' \
|
||||
'======== 代理验证测试 ========' \
|
||||
'======== 第三方代理连接检测 ========' \
|
||||
@@ -44,7 +46,7 @@ grep -q 'localizedCategory' "$ROOT/Shared/RuntimeLog.swift" \
|
||||
|| fail "runtime log categories must be localized when rendered"
|
||||
grep -q 'localizedDetailsText' "$ROOT/App/DiagnosticsView.swift" \
|
||||
|| fail "runtime log details must be localized in the diagnostics UI"
|
||||
grep -q 'String(localized: "诊断日志")' "$ROOT/App/BugReportView.swift" \
|
||||
grep -q 'AppLocalization.string("诊断日志")' "$ROOT/App/BugReportView.swift" \
|
||||
|| fail "generated bug reports must localize their diagnostic section"
|
||||
grep -q 'log(" " + e.localizedMessage)' "$ROOT/App/SetupCoordinator.swift" \
|
||||
|| fail "bug-report verification logs must render stored messages in the active language"
|
||||
@@ -55,4 +57,43 @@ if grep -R -n 'raw.githubusercontent.com/Yu9191/wloc' \
|
||||
fail "deleted Yu9191/wloc repository must not remain a runtime dependency"
|
||||
fi
|
||||
|
||||
# Check the real Foundation lookup path, not just the existence of locale files.
|
||||
grep -q 'developmentLanguage: en' "$ROOT/project.yml" \
|
||||
|| fail "English must be the development-language fallback"
|
||||
grep -q ' - zh-Hant' "$ROOT/project.yml" \
|
||||
|| fail "Traditional Chinese must be a supported region"
|
||||
for locale in zh-Hans zh-Hant; do
|
||||
plutil -lint "$ROOT/Resources/$locale.lproj/Localizable.strings" >/dev/null \
|
||||
|| fail "$locale localization file is invalid"
|
||||
plutil -lint "$ROOT/Resources/$locale.lproj/InfoPlist.strings" >/dev/null \
|
||||
|| fail "$locale permission prompts are invalid"
|
||||
done
|
||||
|
||||
ruby - "$STRINGS" "$ROOT/Resources/zh-Hans.lproj/Localizable.strings" \
|
||||
"$ROOT/Resources/zh-Hant.lproj/Localizable.strings" <<'RUBY' || exit 1
|
||||
paths = ARGV
|
||||
keys = paths.map { |path| File.readlines(path).map { |line| line[/^"((?:\\.|[^"\\])*)"\s*=/, 1] }.compact }
|
||||
abort "FAIL: Chinese tables must cover every English key" unless keys[1] == keys[0] && keys[2] == keys[0]
|
||||
RUBY
|
||||
|
||||
grep -Fq '"虚拟定位" = "虚拟定位";' "$ROOT/Resources/zh-Hans.lproj/Localizable.strings" \
|
||||
|| fail "Simplified Chinese must resolve the source key"
|
||||
grep -Fq '"虚拟定位" = "虛擬定位";' "$ROOT/Resources/zh-Hant.lproj/Localizable.strings" \
|
||||
|| fail "Traditional Chinese must use Traditional characters"
|
||||
|
||||
swift - <<'SWIFT' || fail "language selection differs from expected behavior"
|
||||
import Foundation
|
||||
let available = ["en", "zh-Hans", "zh-Hant"]
|
||||
for (language, expected) in [
|
||||
("zh-CN", "zh-Hans"), ("zh-TW", "zh-Hant"), ("zh-HK", "zh-Hant"),
|
||||
("it-IT", "en"), ("fr-FR", "en")
|
||||
] {
|
||||
let selected = Bundle.preferredLocalizations(from: available, forPreferences: [language]).first
|
||||
guard selected == expected else {
|
||||
fputs("FAIL: \(language) selected \(selected ?? "nil")\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
SWIFT
|
||||
|
||||
echo "PASS: localization and diagnostic export contract"
|
||||
|
||||
@@ -10,8 +10,8 @@ CONTENT="$ROOT/App/ContentView.swift"
|
||||
SETUP="$ROOT/App/FirstSetupView.swift"
|
||||
SETTINGS="$ROOT/App/SettingsView.swift"
|
||||
|
||||
grep -q 'String(localized: "APP模式")' "$MODE" || fail "localized APP mode display name is missing"
|
||||
grep -q 'String(localized: "第三方代理模式")' "$MODE" || fail "localized third-party mode display name is missing"
|
||||
grep -q 'AppLocalization.string("APP模式")' "$MODE" || fail "localized APP mode display name is missing"
|
||||
grep -q 'AppLocalization.string("第三方代理模式")' "$MODE" || fail "localized third-party mode display name is missing"
|
||||
grep -q 'hasSelectedMode' "$MODE" || fail "first-launch mode selection must be persisted"
|
||||
grep -q 'guard runtimeMode.hasSelectedMode else' "$CONTENT" || fail "mode selection must gate startup"
|
||||
grep -q 'phase = .setup' "$CONTENT" || fail "first launch must enter setup before map construction"
|
||||
@@ -106,7 +106,7 @@ grep -q 'setup.requestThirdPartySetup(message: error.localizedDescription)' "$RO
|
||||
|| fail "third-party coordinate sync failures must open the import guide"
|
||||
grep -q '检测到第三方代理连接异常,请检查模块、MITM 和代理连接后重新检测' "$SETUP" \
|
||||
|| fail "runtime repair must explain why the import guide opened"
|
||||
test "$(grep -c 'title: String(localized: \"接口连接失败\")' "$SETUP")" -eq 1 \
|
||||
test "$(grep -c 'title: AppLocalization.string(\"接口连接失败\")' "$SETUP")" -eq 1 \
|
||||
|| fail "third-party failure details must render in one shared result area"
|
||||
grep -Fq '当前客户端:\(client.name)' "$SETUP" \
|
||||
|| fail "third-party failure logs must identify the selected client"
|
||||
@@ -142,7 +142,7 @@ test -s "$ROOT/docs/onboarding-screenshots/shadowrocket/shadowrocket-module-impo
|
||||
grep -q 'presentSuccessfulOperationTip(.activation)' "$ROOT/App/MapHomeView.swift" || fail "third-party save must present the activation tip"
|
||||
grep -q 'presentSuccessfulOperationTip(.deactivation)' "$ROOT/App/MapHomeView.swift" || fail "third-party clear must present the deactivation tip"
|
||||
grep -q 'if spoofState == .active' "$ROOT/App/MapHomeView.swift" || fail "manual help must follow the shared spoof state"
|
||||
grep -q 'MARKETING_VERSION: "1.0.7"' "$ROOT/project.yml" || fail "marketing version must be 1.0.7"
|
||||
grep -q 'CURRENT_PROJECT_VERSION: "8"' "$ROOT/project.yml" || fail "build version must be 8"
|
||||
grep -q 'MARKETING_VERSION: "1.0.8"' "$ROOT/project.yml" || fail "marketing version must be 1.0.8"
|
||||
grep -q 'CURRENT_PROJECT_VERSION: "9"' "$ROOT/project.yml" || fail "build version must be 9"
|
||||
|
||||
echo "PASS: third-party proxy mode contract"
|
||||
|
||||
@@ -25,7 +25,7 @@ import sys
|
||||
with open(sys.argv[1], encoding="utf-8") as handle:
|
||||
config = json.load(handle)
|
||||
|
||||
assert config["latestVersion"] == "1.0.7"
|
||||
assert config["latestVersion"] == "1.0.8"
|
||||
assert config["minimumSupportedVersion"] == "1.0.0"
|
||||
assert "shadowrocket" not in config["communityPromptClients"]
|
||||
assert set(config["communityPromptClients"]) == {
|
||||
@@ -130,7 +130,7 @@ grep -Fq 'SafariView(url: destination.url)' "$BUG_REPORT" \
|
||||
|| fail "the App bug report must not be handed to an external GitHub client"
|
||||
grep -Fq 'App 生成的诊断报告' "$BUG_REPORT" \
|
||||
|| fail "the App must tell users where to paste the generated report"
|
||||
grep -Fq 'String(localized: "第三方客户端")' "$BUG_REPORT" \
|
||||
grep -Fq 'AppLocalization.string("第三方客户端")' "$BUG_REPORT" \
|
||||
|| fail "the generated report must identify the selected third-party client"
|
||||
grep -Fq 'Label("报告 Bug"' "$SETTINGS" \
|
||||
|| fail "Settings must identify the support action as a bug report"
|
||||
|
||||
Reference in New Issue
Block a user