angular-gettext : change language dynamically?

3.8k views Asked by At

I have used angular gettext in my app. I have two languages as of now and want to switch the language in the UI depending on users preferences. I have a button for two languages- DE and EN.

In the controller method i have set the language:

      $scope.changeLang = function (lang) {
                    gettextCatalog.currentLanguage = lang;
                    gettextCatalog.debug = true;

};

On doing this the language doesn't seem to change in the UI. What is the right way to change the language dynamically in UI using angular gettext?

Thanks in advance.

1

There are 1 answers

0
Ruben Vermeersch On

You need to use the setCurrentLanguage method:

gettextCatalog.setCurrentLanguage(lang);

https://angular-gettext.rocketeer.be/dev-guide/api/angular-gettext/