简体   繁体   中英

angular-gettext : change language dynamically?

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.

You need to use the setCurrentLanguage method:

gettextCatalog.setCurrentLanguage(lang);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM