Javascript 我们能否仅使用Intl.NumberFormat显示阿拉伯货币符号?
当前,如果我将货币设置为QAR,它将以英语显示为QAR,并显示为ª.ق。用阿拉伯语Javascript 我们能否仅使用Intl.NumberFormat显示阿拉伯货币符号?,javascript,number-formatting,react-intl,Javascript,Number Formatting,React Intl,当前,如果我将货币设置为QAR,它将以英语显示为QAR,并显示为ª.ق。用阿拉伯语 console.log(new Intl.NumberFormat("en", { style: "currency", currency: "QAR", currencyDisplay: "symbol" }).format(999)); // renders "QAR 999.00"
console.log(new Intl.NumberFormat("en", {
style: "currency",
currency: "QAR",
currencyDisplay: "symbol"
}).format(999));
// renders "QAR 999.00"
console.log(new Intl.NumberFormat("ar", {
style: "currency",
currency: "QAR",
currencyDisplay: "symbol"
}).format(999));
// renders "ر.ق. 999.00"
如果我将货币设置为美元,它将在英语中显示为美元,在阿拉伯语中显示为美元
console.log(new Intl.NumberFormat("en", {
style: "currency",
currency: "USD",
currencyDisplay: "symbol"
}).format(999));
//renders "$999.00"
console.log(new Intl.NumberFormat("ar", {
style: "currency",
currency: "USD",
currencyDisplay: "symbol"
}).format(999));
//renders "US$ 999.00"
我个人不会说阿拉伯语,但我已经得到了阿拉伯语美元的翻译,即“ar”,如果语言是“ar”,货币是“USD”,那么它会将“US$”改为“US$”(例如,“US$”),我在文档中找不到任何东西
提前谢谢
tldr:当语言设置为“ar”时,我想显示“ar”,而不是美元,或者知道仅仅使用Intl.NumberFormat是否不可能。在对Intl.NumberFormat进行了更多修改后,我发现
currencyDisplay
可以设置为name
,这将解决我的问题