From 9c8c32c0e8153fc5e206e5bdcb783a60add3dd70 Mon Sep 17 00:00:00 2001 From: jack <212554440+jackjackbits@users.noreply.github.com> Date: Sat, 28 Nov 2026 16:45:52 -1000 Subject: [PATCH] Use normal case for Settings language dropdown endonyms (#1966) Co-authored-by: jack --- bitchat/Utils/AppLanguageSettings.swift | 8 +++++--- bitchatTests/LocalizationCoverageTests.swift | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bitchat/Utils/AppLanguageSettings.swift b/bitchat/Utils/AppLanguageSettings.swift index 0bde5377..c75767e3 100644 --- a/bitchat/Utils/AppLanguageSettings.swift +++ b/bitchat/Utils/AppLanguageSettings.swift @@ -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 diff --git a/bitchatTests/LocalizationCoverageTests.swift b/bitchatTests/LocalizationCoverageTests.swift index 4bc5e377..fdc5af01 100644 --- a/bitchatTests/LocalizationCoverageTests.swift +++ b/bitchatTests/LocalizationCoverageTests.swift @@ -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