forked from shadowfacts/Tusker
parent
e4eff2d362
commit
2b5d4681e3
|
@ -30,7 +30,13 @@ struct LanguagePicker: View {
|
||||||
if maybeIso639Code.last == "-" {
|
if maybeIso639Code.last == "-" {
|
||||||
maybeIso639Code = maybeIso639Code[..<maybeIso639Code.index(before: maybeIso639Code.endIndex)]
|
maybeIso639Code = maybeIso639Code[..<maybeIso639Code.index(before: maybeIso639Code.endIndex)]
|
||||||
}
|
}
|
||||||
let code = Locale.LanguageCode(String(maybeIso639Code))
|
let identifier = String(maybeIso639Code)
|
||||||
|
// mul (for multiple languages) and unk (unknown) are ISO codes, but not ones that akkoma permits, so we ignore them on all platforms
|
||||||
|
guard identifier != "mul",
|
||||||
|
identifier != "und" else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
let code = Locale.LanguageCode(identifier)
|
||||||
if code.isISOLanguage {
|
if code.isISOLanguage {
|
||||||
return code
|
return code
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,16 +45,13 @@ struct LanguagePicker: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var codeFromPreferredLanguages: Locale.LanguageCode? {
|
private var codeFromPreferredLanguages: Locale.LanguageCode? {
|
||||||
if let identifier = Locale.preferredLanguages.first {
|
if let identifier = Locale.preferredLanguages.first,
|
||||||
let code = Locale.LanguageCode(identifier)
|
case let code = Locale.LanguageCode(identifier),
|
||||||
if code.isISOLanguage {
|
code.isISOLanguage {
|
||||||
return code
|
return code
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var languageCode: Binding<Locale.LanguageCode> {
|
private var languageCode: Binding<Locale.LanguageCode> {
|
||||||
|
@ -138,10 +141,12 @@ private struct LanguagePickerList: View {
|
||||||
// make sure recents always contains the currently selected lang
|
// make sure recents always contains the currently selected lang
|
||||||
let recents = addRecentLang(languageCode)
|
let recents = addRecentLang(languageCode)
|
||||||
recentLangs = recents
|
recentLangs = recents
|
||||||
|
.filter { $0 != "mul" && $0 != "und" }
|
||||||
.map { Lang(code: .init($0)) }
|
.map { Lang(code: .init($0)) }
|
||||||
.sorted { $0.name < $1.name }
|
.sorted { $0.name < $1.name }
|
||||||
|
|
||||||
langs = Locale.LanguageCode.isoLanguageCodes
|
langs = Locale.LanguageCode.isoLanguageCodes
|
||||||
|
.filter { $0.identifier != "mul" && $0.identifier != "und" }
|
||||||
.map { Lang(code: $0) }
|
.map { Lang(code: $0) }
|
||||||
.sorted { $0.name < $1.name }
|
.sorted { $0.name < $1.name }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue