Search code examples
javascriptangularjsangular-translate

How to detect when language changes?


I'm using angular-translate to provide dynamic language support for my app. I am also using a calendar component (http://angular-ui.github.io/ui-calendar/) which doesn't play that well with angular (jQuery roots). To be able to translate it at run time I need to detect when language changes.

Basically I need to know when $translate.use() has been called and the language has been changed.

Is there a way to detect when the language changes so that I can trigger the translations for the calendar component?


Solution

  • This is how I solved it:

        $rootScope.$on('$translateChangeSuccess', function(event, current, previous) {
            // Language has changed
        });