taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 475120e5587e7802331bd99575a7fcc07937cd30
parent 7cd1cdb11d9272db9fcd5b73442152a4a1c4df18
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 23 Nov 2026 17:56:12 +0100

AI: NumberFormatter when region is missing

Diffstat:
MTalerCommon/Helper/CurrencySpecification.swift | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/TalerCommon/Helper/CurrencySpecification.swift b/TalerCommon/Helper/CurrencySpecification.swift @@ -187,7 +187,8 @@ public struct CurrencyInfo: Sendable { if let symbol = formatter.currencySymbol, !symbol.isEmpty { result = result.replacingOccurrences(of: symbol, with: replacement) } - if let code = formatter.currencyCode, !code.isEmpty { + if let code = formatter.currencyCode, !code.isEmpty, + code != formatter.currencySymbol { result = result.replacingOccurrences(of: code, with: replacement) } return result @@ -361,6 +362,9 @@ public class CurrencyFormatter: NumberFormatter, @unchecked Sendable { } formatter.name = specs.name formatter.currency = currency + if (formatter.currencyCode as String?)?.isEmpty ?? true, !currency.isEmpty { + formatter.currencyCode = currency + } // formatter.setCode(to: EUR_4217) // formatter.setSymbol(to: "€") // clamp: specs comes from the exchange and is untrusted; an out-of-range or negative