Romanchuk / angular-i18next

angular v10+ integration with i18next v19.4+
MIT License
131 stars 33 forks source link

i18nextEager pipe seems not to work in v14.0.0-0 #85

Closed faculezcano closed 2 years ago

faculezcano commented 2 years ago

I have a lazy loading module in a rounting with a component that uses i18nextEager pipe, i trigger a lang change but the text isnt updating.

Romanchuk commented 2 years ago

@faculezcano Ok, i'll check it in demo app

faculezcano commented 2 years ago

I've make it work! I was trying to trigger the language change from a custom implementation of LocalStorage setItem (i know nasty shit, it was a PoC) something like:

const originalSetItem = localStorage.setItem;
localStorage.setItem = (key: string, value: string) => {
  if(key === 'lang') {
    i18nService.changeLanguage(value);
  }
  originalSetItem(key, value);
};

The strange thing is that above code trigger the logs of i18next saying that the language was changed, but the texts didn't get rerendered. Finally i've used a CustomEvent to trigger the language change and the texts get rerendered perfectly.

Romanchuk commented 2 years ago

@faculezcano

i18next saying that the language was changed,

It was changed, but zone.js needs event to trigger cd. So you did it correct