diff --git a/lib/Platform/Intl/PlatformIntlApple.mm b/lib/Platform/Intl/PlatformIntlApple.mm index ea062004c64..038085e1085 100644 --- a/lib/Platform/Intl/PlatformIntlApple.mm +++ b/lib/Platform/Intl/PlatformIntlApple.mm @@ -2447,10 +2447,8 @@ uint8_t getCurrencyDigits(std::u16string_view code) { // - compactDisplay is not supported. // - signDisplay is not supported. // - NSNumberFormatter has maximumIntegerDigits, which is 42 by default - auto nsLocale = - [NSLocale localeWithLocaleIdentifier:u16StringToNSString(dataLocale_)]; + std::u16string nsLocaleStr = dataLocale_; nsNumberFormatter_ = [NSNumberFormatter new]; - nsNumberFormatter_.locale = nsLocale; if (style_ == u"decimal") { nsNumberFormatter_.numberStyle = NSNumberFormatterDecimalStyle; if (notation_ == u"scientific") { @@ -2458,7 +2456,7 @@ uint8_t getCurrencyDigits(std::u16string_view code) { } } else if (style_ == u"currency") { nsNumberFormatter_.numberStyle = NSNumberFormatterCurrencyStyle; - nsNumberFormatter_.currencyCode = u16StringToNSString(*currency_); + nsLocaleStr.append(u"@currency=").append(*currency_); if (currencyDisplay_ == u"code") { nsNumberFormatter_.numberStyle = NSNumberFormatterCurrencyISOCodeStyle; } else if (currencyDisplay_ == u"symbol") { @@ -2486,6 +2484,9 @@ uint8_t getCurrencyDigits(std::u16string_view code) { nsNumberFormatter_.maximumSignificantDigits = significantDigits_->maximum; } nsNumberFormatter_.usesGroupingSeparator = useGrouping_; + auto nsLocale = + [NSLocale localeWithLocaleIdentifier:u16StringToNSString(nsLocaleStr)]; + nsNumberFormatter_.locale = nsLocale; if (style_ == u"unit") { nsMeasurementFormatter_ = [NSMeasurementFormatter new]; nsMeasurementFormatter_.numberFormatter = nsNumberFormatter_;