显示与设备语言无关的货币符号

[英]Show currency symbol independent from device's Language


In an app I want to show the same amount of money in each user's localized currency. The problem is that in [NSLocale availableLocaleIdentifiers], it shows that the currency symbol is tied to the language of the device.

在一个应用程序中,我希望在每个用户的本地化货币中显示相同数量的金额。问题是在[NSLocale availableLocaleIdentifiers]中,它显示货币符号与设备的语言相关联。

For the Norwegian Krone for example: locale with identifier "en_NO" gives currency symbol "NOK" but locale with identifier "se_NO" gives currency symbol "kr"

以挪威克朗为例:标识符为“en_NO”的区域设置给出货币符号“NOK”,但标识符为“se_NO”的区域设置给出货币符号“kr”

I want the user with region set as Norway to see the "kr" symbol, even when his currentLocale language is not swedish.

我希望区域设置为挪威的用户可以看到“kr”符号,即使他的currentLocale语言不是瑞典语。

Is there any way around that?

那有什么办法吗?

Thank you!

1 个解决方案

#1


0  

So you want the people using not Swedish see the symbol the same with the people using Swedish.

因此,您希望使用非瑞典语的人看到与使用瑞典语的人一样的符号。

But the currency symbol is fetch with function

但是货币符号是用函数获取的

locale.displayNameForKey(NSLocaleCurrencySymbol, value: code)

which means in different language, the symbol is different, so if you want the all users to see a specific symbol, you should bound the symbol with a specific language.

这意味着在不同的语言中,符号是不同的,因此如果您希望所有用户都能看到特定的符号,您应该使用特定的语言绑定该符号。

Not sure that's a good idea, but you can make a Swedish locale, and get a Swedish symbol with

不确定这是个好主意,但你可以制作一个瑞典语语言环境,并获得瑞典语符号

NSLocale(localeIdentifier: "se_NO").displayNameForKey(NSLocaleCurrencySymbol, value: code)

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/01/22/b790896fac9e9870d3294d21adb70692.html



 
  © 2014-2022 ITdaan.com 联系我们: