Commit 97a916a5 authored by Jü's avatar

set default language accordingly to device's language

parent a349be94
......@@ -38,6 +38,29 @@ public class Localization: Localizable {
}
public extension Localization {
public static func initialLanguage() -> String {
let preferredLanguages = Locale.preferredLanguages
let supportedLanguages = LanguageId.allCases.map { $0.rawValue }
for preferredLanguage in preferredLanguages {
if supportedLanguages.contains(preferredLanguage) {
return preferredLanguage
}
for supportedLanguage in supportedLanguages {
if preferredLanguage.starts(with: supportedLanguage) {
return supportedLanguage
}
}
}
return Constants.defaultLanguage
}
}
public extension Localization {
public func localized(_ age: FiatAge) -> String {
......
......@@ -57,7 +57,7 @@ public class PropertyStore: PropertyStoreProtocol {
if let language = self.defaultStore.object(forKey: TagLanguage) as? String {
return language
}
return Constants.defaultLanguage
return Localization.initialLanguage()
}
set {
self.defaultStore.set(newValue, forKey: TagLanguage)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment