-
Notifications
You must be signed in to change notification settings - Fork 1k
Multiple .use() calls and async rejections #647
Comments
Could you please setup a Plunker on your configuration / setup so we can take a look at the case and the used setup? Thanks :-) |
As a workaround (if possible): use the promise $translate.use('totally-wrong')['finally'](function(){
$translate.use('en-us')
}); So, I would say it can paint the picture:
Can you confirm? |
@fidian +1 on setting up a plunk so we can investigate. Thank you! |
@knalli - The behavior you describe appears to be exactly what I was battling. Here's a plunker. Eliminating the first $translate.use() line lets the translation work. http://plnkr.co/edit/kkGOvQTPliQmVoafsAmx?p=preview |
Ok thanks. |
@fidian Perhaps you can have also a look at 36710e3
|
@knalli - I've looked at the commit and that seems to be a good way to solve the problem. Did you update the plunker to test your change? |
here: http://plnkr.co/edit/Or5tpacOkHf1LEpAkGJQ?p=preview (updating commit) |
Looks like it still is not working. On load the "TITLE" should not just say "TITLE". No interaction should be required to get the title to show the UK version. As it says in the example, "If you see "TITLE" only then translation did not work." |
Hm. It works sometimes. |
Ok, this one works always: http://plnkr.co/edit/Or5tpacOkHf1LEpAkGJQ?p=preview (checking several times). But this one makes a change which we have to revisit first. |
landed as d1745e4 |
I have been tinkering with a custom loader and found that there's a problem when you reject a promise asynchronously but do multiple
.use()
calls.Let's say you are using this code with an asynchronous loader.
The first promise will get rejected. When it does,
$nextLang
will be set toundefined
. When the second promise is fulfilled this$nextLang
does not match and useLanguage() won't get called. When that is skipped,$uses
remains undefined and then a whole world of problems crop up. Even though the language tables are defined and the keys exist,determineTranslationInstant()
will havetable
pointing to an object whose properties are language codes, not the actual translation table. Nothing in the app will get translated.If the rejected promise resolves after the successful one then the translations will work. It's only when the rejection happens first.
The text was updated successfully, but these errors were encountered: