Angular Transloco库货币符号修改求助:如何切换为尼日利亚NGN
解决Transloco货币本地化替换为NGN的方法
第一步:配置全局尼日利亚区域Locale
在你的Locale模块配置文件(如transloco-root.module.ts)中,将默认Locale设置为尼日利亚对应的区域标识en-NG,让管道自动适配该区域的货币规则:import { provideTranslocoLocale } from '@ngneat/transloco-locale'; export const translocoLocaleConfig = { defaultLocale: 'en-NG', // 其他原有配置... }; // 在模块的providers数组中添加配置 provideTranslocoLocale(translocoLocaleConfig)第二步:直接在管道中指定NGN货币代码
如果不需要全局修改Locale,也可以在translocoCurrency管道里明确指定货币代码NGN,同时保留符号格式需求:<span> {{ 1000000 | translocoCurrency: 'symbol' : { minimumFractionDigits: 0, currency: 'NGN' } }} </span>执行后会输出
₦1,000,000(尼日利亚奈拉的标准符号为₦)。补充:若需显示文本形式的NGN而非符号
把管道第一个参数改为'code',即可输出NGN 1,000,000:<span> {{ 1000000 | translocoCurrency: 'code' : { minimumFractionDigits: 0, currency: 'NGN' } }} </span>
内容的提问来源于stack exchange,提问作者fanbondi
相关产品推荐
相关产品推荐

