Files
location-spoofer/App/SystemSettingsNavigator.swift
Syntax-Error-1337 908ac8f734 Add English localization (device-language based)
Add English as an overlay localization following the device language,
keeping Simplified Chinese as the base/development language. Untranslated
strings fall back to Chinese automatically.

- project.yml: set developmentLanguage zh-Hans and knownRegions (zh-Hans/en/Base)
- Resources/en.lproj/{Localizable,InfoPlist}.strings: ~230 English strings
- Resources/zh-Hans.lproj/InfoPlist.strings: Chinese permission prompts
- Restructure ternary Text/Label and String-typed UI messages so they
  localize (String(localized:), LocalizedStringKey helper params); replace
  a .contains("通过") success check with a dedicated flag
- Localize user-facing model/coordinator/error messages across App and Shared

Internal RuntimeLogger logs and diagnostic/report bodies remain in Chinese.
2026-09-10 01:05:45 +08:00

73 lines
2.2 KiB
Swift

import Foundation
import UIKit
enum SystemSettingsDestination {
case appPermissions
case general
case wifi
case locationServices
var preferredURL: URL? {
let value: String
switch self {
case .appPermissions:
value = UIApplication.openSettingsURLString
case .general:
value = "App-Prefs:General"
case .wifi:
value = "App-Prefs:WIFI"
case .locationServices:
value = "App-Prefs:Privacy&path=LOCATION"
}
return URL(string: value)
}
var manualPath: String {
switch self {
case .appPermissions:
return String(localized: "请手动打开「设置」,找到本 App 后检查定位权限。")
case .general:
return String(localized: "请手动打开「设置 → 通用」。")
case .wifi:
return String(localized: "请手动打开「设置 → 无线局域网」,进入当前 Wi-Fi 的详情页。")
case .locationServices:
return String(localized: "请手动打开「设置 → 隐私与安全性 → 定位服务」。")
}
}
}
@MainActor
enum SystemSettingsNavigator {
static func open(
_ destination: SystemSettingsDestination,
completion: @escaping @MainActor @Sendable (String?) -> Void = { _ in }
) {
let appSettingsURL = URL(string: UIApplication.openSettingsURLString)
let preferredURL = destination.preferredURL
openURL(preferredURL) { openedPreferred in
guard !openedPreferred else {
completion(nil)
return
}
guard preferredURL != appSettingsURL else {
completion(destination.manualPath)
return
}
openURL(appSettingsURL) { openedFallback in
completion(openedFallback ? nil : destination.manualPath)
}
}
}
private static func openURL(_ url: URL?, completion: @escaping @MainActor @Sendable (Bool) -> Void) {
guard let url else {
completion(false)
return
}
UIApplication.shared.open(url, options: [:]) { opened in
completion(opened)
}
}
}