feat(settings): 新增三语即时切换并记录验收与专项边界
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import Foundation
|
||||
|
||||
/// Native AppKit labels do not consume SwiftUI's locale environment.
|
||||
nonisolated enum AppLocalization {
|
||||
static func string(_ key: String, locale: Locale, bundle: Bundle = .main) -> String {
|
||||
let identifier = Bundle.preferredLocalizations(from: AppLanguage.supported,
|
||||
forPreferences: [locale.identifier]).first ?? "en"
|
||||
guard let path = bundle.path(forResource: identifier, ofType: "lproj"),
|
||||
let localized = Bundle(path: path) else {
|
||||
return bundle.localizedString(forKey: key, value: nil, table: nil)
|
||||
}
|
||||
return localized.localizedString(forKey: key, value: nil, table: nil)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user