Angular-Translate highlight active language


#1

hey,

how can I set the state to active/true for the preferredLanguage?

<ion-list>
<ion-radio ng-click="changeLanguage('de')">
  <div class="flag"><img ng-src="img/settings/de.png" alt="DE"></div> Deutsch
</ion-radio>
<ion-radio ng-click="changeLanguage('en')">
  <div class="flag"><img ng-src="img/settings/en.png" alt="EN"></div> English
</ion-radio>
<ion-radio ng-click="changeLanguage('fr')">
  <div class="flag"><img ng-src="img/settings/fr.png" alt="FR"></div> Francis
</ion-radio>
<ion-radio ng-click="changeLanguage('it')">
  <div class="flag"><img ng-src="img/settings/it.png" alt="IT"></div> Italiano
</ion-radio>
</ion-list>

&

.controller('SettingsCtrl', function ($scope, $translate) {
$scope.changeLanguage = function (key) {
    $translate.use(key);
  };
})

.config(function($stateProvider, $urlRouterProvider, $translateProvider) {
$translateProvider.translations('de', {
    hello_message: "Deutsch",
});

$translateProvider.translations('en', {
    hello_message: "English",
});
$translateProvider.translations('fr', {
    hello_message: "Francis",
});

$translateProvider.translations('it', {
    hello_message: "Italiano",
});

$translateProvider.preferredLanguage("en");
$translateProvider.fallbackLanguage("en");
})

.run(function($ionicPlatform, $translate) {
$ionicPlatform.ready(function() {
    if(typeof navigator.globalization !== "undefined") {
        navigator.globalization.getPreferredLanguage(function(language) {
            $translate.use((language.value).split("-")[0]).then(function(data) {
                console.log("SUCCESS -> " + data);
            }, function(error) {
                console.log("ERROR -> " + error);
            });
        }, null);
    }
});

})