I have successfully integrated the $translate project from this source into my AngularJS application.
While I have configured the default language in my app.config() using $translateProvider, I am now wondering how to retrieve the selected language within the langCtrl controller. Is there a get function provided by $translate for this purpose?
angular.module('app').config(['$translateProvider', function($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: 'locale-',
suffix: '.json'
});
$translateProvider.preferredLanguage('en');
}]);
angular.module('app').controller('langCtrl', ['$scope', '$translate',
function ($scope, $translate) {
$scope.lang = ''; //I need to assign the selected language here
$scope.setLanguage = function (langKey) {
$translate.use(langKey);
};
}]);