Match currency search against issuing country names too
Searching "Japan" now finds JPY, "Canada" finds CAD, etc. — matching just the currency's own display name wasn't enough, since e.g. "Canadian Dollar" doesn't contain "Canada" as a substring. Adds a per-platform regionDisplayName(regionCode) (java.util.Locale on JVM/Android, NSLocale on Apple, Intl.DisplayNames on web) and reuses CurrencyFlag.kt's currency-to-country-code derivation (now extracted as issuingCountryCodes) to look up the country/countries behind a currency code. "EU" is hardcoded to "European Union" since it's not a real ISO 3166-1 code platform locale data can resolve. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FXcrACM5sok3M1KQJ8kByy
This commit is contained in:
@@ -37,3 +37,9 @@ actual fun currencyDecimalDigits(code: String): Int = try {
|
||||
} catch (e: IllegalArgumentException) {
|
||||
2
|
||||
}
|
||||
|
||||
@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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user