在我的角度应用程序中,我试图只获取阿拉伯语的国家名称,并使用i18n-iso- country库保存其英文代码。我是用npm安装的
npm -i i18n-iso国家
然后,在我的组件中,我像这样导入了它:
进口*作为i18IsoCountries从‘i18n-iso-国家’;
我试着用ar代替en,但它不起作用
getCountries(): { id: string; name: string }[] {
return Object.entries(countriesLib.getNames('ar', { select: 'official' })).map((entry) => {
return {
id: entry[0],
name: entry[1]
};
});
}
getCountry(countryKey: string): string {
return countriesLib.getName(countryKey, 'en');
}
发布于 2022-10-16 11:23:41
您必须导入ar语言json文件。
countriesLib.registerLocale(require('i18n-iso-countries/langs/ar.json'));
https://stackoverflow.com/questions/74084411
复制相似问题