michaelwittig / node-i18n-iso-countries

i18n for ISO 3166-1 country codes
MIT License
807 stars 261 forks source link

Does not work well with Angular 10 #186

Open jsgoupil opened 4 years ago

jsgoupil commented 4 years ago

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?

KingDarBoja commented 4 years ago

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.

capc0 commented 4 years ago

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

KingDarBoja commented 4 years ago

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

HannaSanford commented 3 years ago

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