mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-29 08:29:22 +00:00
Use normal case for Settings language dropdown endonyms (#1966)
Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
1 parent
5830f66f63
commit
9c8c32c0e8
2 files changed
+15
-3
No files matched your search
@@ -17,12 +17,14 @@ enum AppLanguageSettings {
|
||||
.sorted { endonym(for: $0).localizedCaseInsensitiveCompare(endonym(for: $1)) == .orderedAscending }
|
||||
}
|
||||
|
||||
/// The language's name in that language ("فارسی", "한국어") so every user
|
||||
/// can find their own entry regardless of the current UI language.
|
||||
/// The language's name in that language ("English", "Français", "فارسی",
|
||||
/// "한국어") with its leading character capitalized for standalone menu rows
|
||||
/// so every user can find their own entry regardless of the current UI language.
|
||||
static func endonym(for code: String) -> String {
|
||||
let locale = Locale(identifier: code)
|
||||
let name = locale.localizedString(forIdentifier: code) ?? code
|
||||
return name.lowercased(with: locale)
|
||||
guard let first = name.first else { return name }
|
||||
return String(first).uppercased(with: locale) + name.dropFirst()
|
||||
}
|
||||
|
||||
/// Persists the override (nil clears it). AppleLanguages drives the
|
||||
|
||||
@@ -440,6 +440,16 @@ struct LocalizationCoverageTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func languageEndonymsUseNormalCaseForMenuDisplay() {
|
||||
#expect(AppLanguageSettings.endonym(for: "en") == "English")
|
||||
#expect(AppLanguageSettings.endonym(for: "de") == "Deutsch")
|
||||
#expect(AppLanguageSettings.endonym(for: "es") == "Español")
|
||||
#expect(AppLanguageSettings.endonym(for: "fr") == "Français")
|
||||
#expect(AppLanguageSettings.endonym(for: "pt-BR") == "Português (Brasil)")
|
||||
#expect(AppLanguageSettings.endonym(for: "ru") == "Русский")
|
||||
#expect(AppLanguageSettings.endonym(for: "vi") == "Tiếng Việt")
|
||||
}
|
||||
|
||||
/// A literal `String(localized:)` key, with where it was written.
|
||||
private struct KeyReference {
|
||||
let key: String
|
||||
|
||||
Reference in new issue
Block a user