Search code examples
angular-translate

angular-translate: translate-cloak does not work in v2.4


I just updated to v2.4 of angular-translate: http://angular-translate.github.io and found that translate-cloak is not working. It used to work in v2.2. The 'translate-cloak' class is now never removed from the tag which has the translate-cloak attribute.

I have a plunker to demonstrate the problem:

http://plnkr.co/edit/NOxGMEqTy4FsZBSIK0zl

If it works, it should show two lines. The second line is in a div which has the translate-cloak attribute.

You can change line 9 of index.html to the line below (change from v2.4 to v2.2 of angular-translate) to see it works in v2.2.

<script src="angular-translate.v2.2.js"></script>

Did I missed something?


Solution

  • The commit 98fe64 is a fix for https://github.com/angular-translate/angular-translate/issues/658 (event was not fired always). Actually it should be fired MORE often than before instead of less than before.

    Looking at your example, I can see the language seems to be loaded right before parsing the directive and therefor the listener w/ console outputs.

    console.log('$translateChangeEnd');
    

    This means that issue is not related to the change ~success -> ~end, but related to non deterministic (even not in this particular example) order of resource loading, xhr responses and component parsings and compiles.

    I've added a

    $rootScope.$emit('$translateChangeEnd', { language: translation.key });
    

    but we have to check if this covers all.

    See fork http://plnkr.co/edit/kawPEyjPpPRtJvJzqLeD?p=preview

    See my outstanding patch https://github.com/angular-translate/angular-translate/commit/e5ef6ab609d6a58defd371ca8239e8054cab718e

    (Disclaimer: I'm from the angular-translate core team.)