en-IN 区域设置不适用于 angular 货币管道
en-IN locale not working for angular currency pipe
来自 Wikipedia:
The Indian numbering system uses separators differently from the international norm. Instead of grouping digits by threes as in the international system, It groups the rightmost three digits together (till the hundreds place) and thereafter groups by sets of two digits. One trillion would thus be written as 10,00,00,00,00,000.
toLocaleString
JavaScript returns 的
toLocaleString
函数以 en-IN
语言环境的正确格式。
(123456789).toLocaleString('en-IN', {
style: 'currency',
currency: 'INR',
minimumFractionDigits: 2,
maximumFractionDigits: 2
}) // ₹ 12,34,56,789.00
但是 Angular 的货币管道 return 与 en-IN
语言环境的输出不同。我需要创建自定义管道吗?
{{ 123456789 | currency : 'INR' : 'symbol': '1.2-2' : 'en-IN' }}
<!-- ₹123,456,789.00 -->
在 app.module.ts
中添加以下行启用印度数字格式。如果您想使用多个语言环境,还给出了示例。
import { registerLocaleData } from '@angular/common';
import localeIn from '@angular/common/locales/en-IN';
registerLocaleData(localeIn);
import localeAr from '@angular/common/locales/ar-EG';
registerLocaleData(localeAr);
<p>
<!-- ₹ 12,34,56,789.00 -->
{{ 123456789 | currency : 'INR' : 'symbol': '1.2-2' : 'en-IN' }}
<br/>
<!-- د.إ. 123,456,789.00 -->
{{ 123456789 | currency : 'AED' : 'symbol': '1.2-2' : 'ar-EG' }}
</p>
来自 Wikipedia:
The Indian numbering system uses separators differently from the international norm. Instead of grouping digits by threes as in the international system, It groups the rightmost three digits together (till the hundreds place) and thereafter groups by sets of two digits. One trillion would thus be written as 10,00,00,00,00,000.
toLocaleString
JavaScript returns 的
toLocaleString
函数以 en-IN
语言环境的正确格式。
(123456789).toLocaleString('en-IN', {
style: 'currency',
currency: 'INR',
minimumFractionDigits: 2,
maximumFractionDigits: 2
}) // ₹ 12,34,56,789.00
但是 Angular 的货币管道 return 与 en-IN
语言环境的输出不同。我需要创建自定义管道吗?
{{ 123456789 | currency : 'INR' : 'symbol': '1.2-2' : 'en-IN' }}
<!-- ₹123,456,789.00 -->
在 app.module.ts
中添加以下行启用印度数字格式。如果您想使用多个语言环境,还给出了示例。
import { registerLocaleData } from '@angular/common';
import localeIn from '@angular/common/locales/en-IN';
registerLocaleData(localeIn);
import localeAr from '@angular/common/locales/ar-EG';
registerLocaleData(localeAr);
<p>
<!-- ₹ 12,34,56,789.00 -->
{{ 123456789 | currency : 'INR' : 'symbol': '1.2-2' : 'en-IN' }}
<br/>
<!-- د.إ. 123,456,789.00 -->
{{ 123456789 | currency : 'AED' : 'symbol': '1.2-2' : 'ar-EG' }}
</p>