Files
Kymo/kymo/UI/Components/AppLocalization.swift
T

15 lines
715 B
Swift

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)
}
}