node-i18n-iso-countries icon indicating copy to clipboard operation
node-i18n-iso-countries copied to clipboard

Does not work well with Angular 10

Open jsgoupil opened this issue 4 years ago • 4 comments

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)

image

See this: https://stackoverflow.com/questions/52600104/how-to-use-i18n-iso-countries-in-angular-6

Do you have any recommendations?

jsgoupil avatar Jun 30 '20 01:06 jsgoupil

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.

KingDarBoja avatar Aug 19 '20 21:08 KingDarBoja

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

capc0 avatar Oct 06 '20 12:10 capc0

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).

KingDarBoja avatar Oct 06 '20 14:10 KingDarBoja

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

HannaSanford avatar Jun 08 '21 16:06 HannaSanford