labels not updating after changing language
See original GitHub issueI ran into an issue when changing the language dynamically, using ‘$i18next.options.lng’ in a controller. The labels are not updated automatically to the new language. I see the i18n cookie changing to the new language, so the language change has been executed correctly. However, the labels are only updated when I navigate away from the screen and back (this is client side routing with angular routing and does not trigger a page reload). This last observation made me believe a digest cycle was missing after the language change, but manually triggering a digest showed that a digest was in fact already happening. Any idea why the labels aren’t updated immediately?
Lib versions: Ionic 1.0.0 with angular 1.3.13 i18next 1.10.1 ng-i18next 0.5.0, but I tested with various previous versions, to no avail
Config:
$i18nextProvider.options = {
useCookie: true,
fallbackLng: 'nl-BE',
ns: 'translations',
resGetPath: 'locales/__ns__.__lng__.json',
getAsync: false
};
Controller code (triggered on selecting a language from a <select> dropdown):
$scope.changeLanguage = function (lngCode) {
$i18next.options.lng = lngCode;
}
Any help would be much appreciated!
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Sounds like your filter isn’t stateful.
Have a look at this article: http://blog.thoughtram.io/angularjs/2014/11/19/exploring-angular-1.3-stateful-filters.html We had a similar issue: https://github.com/i18next/ng-i18next/pull/66
Is your filter stateful? 😃 Maybe this helps.
Regards, Andre
Well, I didn’t know about this, too… But thanks to the community we were able to fix this. 😃