简体   繁体   English

Ionic3中的CurrencyPipe和currencyCode

[英]CurrencyPipe and currencyCode in Ionic3

I'm developing a application where I want currency will be show with currency code depending locale configuration at the device. 我正在开发一个应用程序,我希望根据设备上的语言环境配置以货币代码显示货币。 I'm trying with globalization native ionic plugin. 我正在尝试使用全球化本地离子插件。 All works fine if I write in my code the currency Code (eg EUR) but I'd like get it from locale config. 如果我在代码中编写货币代码(例如EUR),则一切正常,但我想从区域设置中获取。

I can't find any way to do this. 我找不到任何方法可以做到这一点。 All examples I've found are writing currency Code. 我发现的所有示例都在编写货币代码。 Then I'm asking if I'm trying to do something imposible. 然后我问我是否正在尝试做一些不可能的事情。

Thanks... 谢谢...

After doing some digging I don't think there is a straighforward way of getting the currency from device information or locale. 经过一些挖掘后,我认为没有从设备信息或语言环境中获取货币的直接方法。

The reason may be that there is not obvious link between language, location and currency used for making purchases. 原因可能是购物所用的语言,位置和货币之间没有明显的联系。

The only external hint that you could use, might be through using the "In App Purchase 2" Ionic native plugin. 您唯一可以使用的外部提示可能是通过使用“ In App Purchase 2” Ionic本机插件。

This does require activating In App Billing for your app in the Google Play store, or In App Purchase in the Apple App Store. 这确实需要在Google Play商店中为您的应用激活In App Billing,或在Apple App Store中激活In App Purchase。 Then, once you've created (non-free) products, you could check which currency is used in the product listings you receive from the store and take it as a hint regarding the user's preferred currency. 然后,一旦创建了(非免费)产品,就可以检查从商店收到的产品清单中使用了哪种货币,并将其作为有关用户首选货币的提示。

Other than that my best guess is to assume a default currency and manually assign a specific currency per locale. 除此之外,我的最佳猜测是假设使用默认货币,然后按每个区域手动分配特定货币。

What I have tested 我测试过的

None of these gave me any direct info regarding the user's preferred currency. 这些都没有给我任何有关用户首选货币的直接信息。

I'd like to get a better answer... 我想得到一个更好的答案...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM