Resolve "EU" through platform locale data instead of hardcoding it

Verified directly (java.util.Locale, NSLocale, and Intl.DisplayNames
all tested outside the app) that every platform's locale data resolves
"EU" correctly on its own — "European Union" in en, "Union européenne"
in fr, "Europäische Union" in de, etc. — via CLDR, which defines "EU"
as a grouping in its own right despite it not being a real ISO 3166-1
country code. The hardcoded English fallback was based on an
assumption that was never actually verified.

Removes the special case from the shared code entirely. That required
two platform-side fixes to stop blocking "EU" from ever reaching the
platform lookup:
- JVM/Android: dropped the Locale.getISOCountries() membership guard
  (which excluded "EU") in favor of detecting an unresolvable code by
  getDisplayCountry() echoing it back unchanged.
- Web: jsRegionDisplayName() was hardcoding locale 'en' for
  Intl.DisplayNames — changed to undefined (the browser's own locale),
  matching what the other platforms already did. Without this fix,
  "EU" would resolve, but only ever in English on web.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
2026-09-10 13:21:24 +03:00
co-authored by Claude Sonnet 5
parent 4f190308a3
commit bb4602e8fa
5 changed files with 38 additions and 29 deletions
@@ -38,10 +38,12 @@ actual fun currencyDecimalDigits(code: String): Int = try {
2
}
// Doesn't gate on Locale.getISOCountries() — that would incorrectly exclude "EU", which isn't a
// real ISO 3166-1 code but which getDisplayCountry() resolves correctly anyway (CLDR defines it
// as a grouping in its own right). A genuinely-unresolvable code's display name just echoes the
// code back unchanged, so that's the signal used to report "unknown" instead.
@Suppress("DEPRECATION") // Locale(language, country) still works fine; Locale.of() needs newer Android API levels.
actual fun regionDisplayName(regionCode: String): String? {
if (regionCode !in Locale.getISOCountries()) return null
return Locale("", regionCode).getDisplayCountry(Locale.getDefault())
}
actual fun regionDisplayName(regionCode: String): String? =
Locale("", regionCode).getDisplayCountry(Locale.getDefault()).takeIf { it != regionCode }
actual fun supportsFlagEmoji(): Boolean = true