diff --git a/Outpost/Features/Account/SettingsView.swift b/Outpost/Features/Account/SettingsView.swift index b68cede..d125f2b 100644 --- a/Outpost/Features/Account/SettingsView.swift +++ b/Outpost/Features/Account/SettingsView.swift @@ -375,7 +375,7 @@ struct SettingsView: View { ProgressView().controlSize(.small) } else { Picker("Language", selection: languageBinding) { - ForEach(OutlineLocale.all) { locale in + ForEach(displayedLocales) { locale in Text(locale.label).tag(locale.code) } } @@ -443,6 +443,20 @@ struct SettingsView: View { ) } + /// `OutlineLocale.all` is a curated subset, not Outline's full list — + /// a self-hosted server can report a code we don't know about (seen + /// live: "en_GB"). `Picker` needs a `Text` for every possible selection + /// or it logs "invalid tag" and its displayed value goes undefined — + /// appending the current code here (using itself as the label, same + /// fallback `OutlineLocale.label(for:)` already uses) guarantees a + /// match no matter what the server sends. + private var displayedLocales: [OutlineLocale] { + guard let current = session.userLanguage, !OutlineLocale.all.contains(where: { $0.code == current }) else { + return OutlineLocale.all + } + return OutlineLocale.all + [OutlineLocale(code: current, label: OutlineLocale.label(for: current))] + } + private var languageBinding: Binding { Binding( get: { session.userLanguage ?? "en_US" }, diff --git a/Outpost/Support/OutlineLocale.swift b/Outpost/Support/OutlineLocale.swift index 4099726..ab79106 100644 --- a/Outpost/Support/OutlineLocale.swift +++ b/Outpost/Support/OutlineLocale.swift @@ -13,6 +13,7 @@ struct OutlineLocale: Identifiable, Hashable { static let all: [OutlineLocale] = [ OutlineLocale(code: "en_US", label: "English (US)"), + OutlineLocale(code: "en_GB", label: "English (UK)"), OutlineLocale(code: "de_DE", label: "Deutsch"), OutlineLocale(code: "fr_FR", label: "Français"), OutlineLocale(code: "es_ES", label: "Español"),