How to list all languages ​​loaded using angular -translate

I can not find it in the docs or angular-translate api. How to download all downloaded languages ​​using angular translate?

Assuming I have a LanguageCtrl:

angular.module('myApp') .controller('LanguageCtrl', ['$translate', '$scope', function ($translate, $scope) { $scope.switchLang = function (lang) { $translate.use(lang); }; $scope.currentLang = function () { return $translate.use(); }; $scope.isCurrentLang = function (lang) { return $translate.use() === lang; }; $scope.languages = function(){ return $translate.IS_THERE_AN_API_FUNCTION_TO_GET_ALL_LANGUAGES(); } }]); 

And I load these languages:

 angular.module('myApp', ['pascalprecht.translate']) .config(['$translateProvider', function ($translateProvider) { $translateProvider.translations('de', de); $translateProvider.translations('fr', fr); $translateProvider.translations('en', en); $translateProvider.preferredLanguage('en'); }]); 

Now I would like to display all languages:

 <ul ng-controller="LanguageCtrl"> <li ng-repeat="lang in languages" ng-class="{active: isCurrentLang(lang)}"> <a href="" ng-click="switchLang(lang)">lang</a> </li> </ul> 
+6
source share
2 answers

Updated answer:

 /** * @description * This function simply returns the registered language keys being defined before in the config phase * With this, an application can use the array to provide a language selection dropdown or similar * without any additional effort * * @returns {object} returns the list of possibly registered language keys and mapping or null if not defined */ $translate.getAvailableLanguageKeys(); /* * To register language keys, use the following function in your configuration: */ $translateProvider.registerAvailableLanguageKeys(['en', 'de']); 
+2
source

Unfortunately, there is still no API for retrieving all registered languages. In short: this is not possible yet .

If you want, you can open the problem on github to offer this feature. However, keep in mind that when using asynchronous loaders, languages ​​are not registered until they are loaded.

+10
source

All Articles