Refactor auto-translations and add caching

Changelog-Added: Add auto-translation caching to ruduce api usage
Closes: #843
This commit is contained in:
2023-03-30 11:15:35 -04:00
committed by William Casarin
parent 5a238502cb
commit ae82114a33
12 changed files with 225 additions and 115 deletions

View File

@@ -22,6 +22,14 @@ func localizedStringFormat(key: String, locale: Locale?) -> String {
return bundle.localizedString(forKey: key, value: fallback, table: nil)
}
func currentLanguage() -> String {
if #available(iOS 16, *) {
return Locale.current.language.languageCode?.identifier ?? "en"
} else {
return Locale.current.languageCode ?? "en"
}
}
/**
Removes the variant part of a locale code so that it contains only the language code.
*/