feat: add localization support (zh-Hans + en) with instant language switching

This commit is contained in:
lijingjun 2026-05-30 15:24:32 +08:00
parent 5f2ed6667b
commit a18d8b5d5c
7 changed files with 1869 additions and 63 deletions

View file

@ -24,57 +24,57 @@ enum AppFeature: String, CaseIterable, Identifiable {
var title: String {
switch self {
case .home:
return "Apps"
return "Apps".localized
case .scripts:
return "Scripts"
return "Scripts".localized
case .tools:
return "Tools"
return "Tools".localized
case .news:
return "News"
return "News".localized
case .console:
return "Console"
return "Console".localized
case .deviceInfo:
return "Device Info"
return "Device Info".localized
case .profiles:
return "App Expiry"
return "App Expiry".localized
case .processes:
return "Processes"
return "Processes".localized
case .location:
return "Location"
return "Location".localized
case .settings:
return "Settings"
return "Settings".localized
}
}
var detail: String {
switch self {
case .home:
return "Manage installed apps"
return "Manage installed apps".localized
case .scripts:
return "Manage and run JS scripts"
return "Manage and run JS scripts".localized
case .tools:
return "Access additional tools"
return "Access additional tools".localized
case .news:
return "Latest StikDebug updates"
return "Latest StikDebug updates".localized
case .console:
return "Live device logs"
return "Live device logs".localized
case .deviceInfo:
return "View detailed device metadata"
return "View detailed device metadata".localized
case .profiles:
return "Check app expiration dates"
return "Check app expiration dates".localized
case .processes:
return "Inspect running apps"
return "Inspect running apps".localized
case .location:
return "Simulate GPS location"
return "Simulate GPS location".localized
case .settings:
return "Configure StikDebug"
return "Configure StikDebug".localized
}
}
var toolTitle: String {
switch self {
case .location:
return "Location Simulation"
return "Location Simulation".localized
default:
return title
}

View file

@ -0,0 +1,18 @@
import SwiftUI
@Observable
class LanguageManager {
static let shared = LanguageManager()
var language: String {
didSet {
UserDefaults.standard.set([language], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
}
}
init() {
let saved = UserDefaults.standard.stringArray(forKey: "AppleLanguages")?.first ?? "zh-Hans"
self.language = saved
}
}