Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Finally invoke "clearNextLangAndPromise" when already loading a translation table #1813

Open
nickshoe opened this issue Nov 24, 2017 · 0 comments
Milestone

Comments

@nickshoe
Copy link

nickshoe commented Nov 24, 2017

Hi,

I'm experiencing a bug in Lazy loading at runtime with partial loaders.

After invoking $translate.use with a new language, the page is not being translated and so the translation keys are shown. This error occurs sometimes and I think it's due to some timing related aspect (race conditions?).
After having debugged quite a bit, it occurred me a workaround:
$translate.use($lankKey).then(function () { $translate.refresh(); });
But I think that this is pretty ugly because of poor performances.

After having debugged quite a bit and having read the code, this fix occurred me:

Put the code below (already present in the first if branch in the $translate.use method) also in the second branch (see the link below for the line):

langPromises[key]['finally'](function () {
          clearNextLangAndPromise(key);
})['catch'](angular.noop); // we don't care about errors (clearing)

This way, when the language is being changed by the use method, the code enters in the first branch (thanks to the langPromise of the new language key being set undefined by the code above, even when the translation table is already being loaded).

@knalli knalli added this to the 2.18.0 milestone Mar 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants