[英]Globalize.format not formatting the date to “dd/MM/yyyy” format
[英]globalize numbers and currency: en-IN/INR format not working as expected
我有兩種嘗試使用globalize編寫的方法。 一種用於格式化數字,另一種用於格式化貨幣。
function currencyFormatter(value, locale, fieldDefinition) {
var formatter = Globalize('en').currencyFormatter( 'INR' )
return formatter( value )
}
function numberFormatter(value, locale, fieldDefinition){
var formatter = Globalize('en').numberFormatter()
return formatter( value )
}
當我將'en'語言環境與'INR'貨幣代碼用於currencyFormatter或'en'用於numberFormatter時,我期望看到₹12,34,567.89之類的東西,但是在兩種情況下我得到的都是₹1,234,567.89 (減去貨幣符號) (數字)。 我查看了我的node_modules文件夾cldr-data / main / en-IN / numbers.json並發現了以下內容:
"percentFormats-numberSystem-latn": {
"standard": "#,##,##0%"
},
"currencyFormats-numberSystem-latn": {
"currencySpacing": {
"beforeCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
},
"afterCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
}
},
"standard": "¤ #,##,##0.00",
"accounting": "¤#,##0.00;(¤#,##0.00)",
我還去了CLDR網站並挖出了我認為是格式文件(en-IN.xml)的文件,發現了這一點:
<rulesetGrouping type="OrdinalRules">
<ruleset type="digits-ordinal">
<rbnfrule value="-x">−→→;</rbnfrule>
<rbnfrule value="0">=#,##0=$(ordinal,one{st}two{nd}few{rd}other{th})$;</rbnfrule>
</ruleset>
</rulesetGrouping>
這些都支持我們得到的結果是正確的,並且我們對預期的假設是錯誤的。 但是,如果您在Internet上查找,則有許多知名網站都說我們的假設正確,而結果卻不正確。
這使我處於不知所措的狀態。 誰是對的? 您能幫助我們回答這個問題嗎?
另外,如果出於任何原因想要更改默認格式,是否可以“覆蓋”默認格式?
您應該使用en-IN
作為印度所說的英語,即Globalize('en-IN')
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.