node-i18n-iso-countries
node-i18n-iso-countries copied to clipboard
Does not work well with Angular 10
Somehow, your project does not load properly with Angular 10. I used your project forever and starting Angular 10, I get the following error:
ERROR in ./src/app/controls/input-address-country/input-address-country.component.ts 35:16-24
"export 'getNames' was not found in 'i18n-iso-countries'
ERROR in ./src/polyfills.ts 62:0-14
"export 'registerLocale' was not found in 'i18n-iso-countries'
I load the code like this:
import * as countries from 'i18n-iso-countries';
/// ...
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
countries.getNames('en');
It used to work great. Now I try to use your method by using "require" and it doesn't work either (you propose this in your readme)
See this: https://stackoverflow.com/questions/52600104/how-to-use-i18n-iso-countries-in-angular-6
Do you have any recommendations?
I have been using this on Angular 10 by following the same steps like the StackOverflow link. The only difference I have on my setup is calling i18nIsoCountries.registerLocale(require('i18n-iso-countries/langs/en.json'));
on my component constructor instead of the ngOnInit hook.
FYI this is how I am doing it in angular 10:
import * as countries from 'i18n-iso-countries';
import countryDataDe from 'i18n-iso-countries/langs/de.json';
countries.registerLocale(countryDataDe);
in the tsconfig.json I have "resolveJsonModule": true
enabled
You can also use it as ES Modules by using #188 PR or https://github.com/lula/-ngx-countries (which is slighty outdated but works pretty well).
FYI this is how I am doing it in angular 10:
import * as countries from 'i18n-iso-countries'; import countryDataDe from 'i18n-iso-countries/langs/de.json'; countries.registerLocale(countryDataDe);
in the tsconfig.json I have
"resolveJsonModule": true
enabled
This isn't ideal as it doesn't allow for importing the languages dynamically