mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
fix localeWithStrings globally (#30)
This commit is contained in:
parent
3244281676
commit
397d8fcfaa
@ -13,7 +13,16 @@ private let systemLocaleRegionSuffix: String = {
|
|||||||
public let usEnglishLocale = Locale(identifier: "en_US")
|
public let usEnglishLocale = Locale(identifier: "en_US")
|
||||||
|
|
||||||
public func localeWithStrings(_ strings: PresentationStrings) -> Locale {
|
public func localeWithStrings(_ strings: PresentationStrings) -> Locale {
|
||||||
let languageCode = strings.baseLanguageCode
|
var languageCode = strings.baseLanguageCode
|
||||||
|
|
||||||
|
// MARK: - Swiftgram fix for locale bugs, like location crash
|
||||||
|
if #available(iOS 18, *) {
|
||||||
|
let rawSuffix = "-raw"
|
||||||
|
if languageCode.hasSuffix(rawSuffix) {
|
||||||
|
languageCode = String(languageCode.dropLast(rawSuffix.count))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let code = languageCode + systemLocaleRegionSuffix
|
let code = languageCode + systemLocaleRegionSuffix
|
||||||
return Locale(identifier: code)
|
return Locale(identifier: code)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user