'use strict';
AMIApp.controller('LanguageCtrl', ['$scope', '$timeout', '$location', '$window', '$translate', 'AMIRequest', '$cookies', 'urls', function ($scope, $timeout, $location, $window, $translate, AMIRequest, $cookies, urls) {

  // $translate.onReady(function(){
  //   $translate(['logo_src']).then(function (translation) {
  //     $scope.logo_src = translation["logo_src"];
  //   });
  // });

  $scope.languages = {
    "en": {
      "title": "English",
      "languageCode": "en",
      "languageCodeMoment": "en"
    },
    "aa": {
      "title": "Elvish",
      "languageCode": "aa",
      "languageCodeMoment": "en"
    }
  };

    $scope.lang = $scope.languages[$translate.use()];
    
    $scope.selectLanguage = function(lang){
      $translate.use(lang.languageCode);
      urls.setLanguageCode(lang.languageCode);
      moment.lang(lang.languageCodeMoment);
      $cookies.put('languageCode', lang.languageCode);
      AMIRequest.drop('operator');
    }
    $scope.$watch(function() {
      $scope.showControls = (AMIRequest.hierarchy.indexOf($location.path().substring(1)) <= 1);
      $scope.lang = $scope.languages[$translate.use()];
    });
    
}]);
AMIApp.controller('LangStyle', ['$scope', '$translate', function ($scope, $translate) {

    $scope.lang = $translate.use();
    
    $scope.$watch(function() {
      $scope.lang = $translate.use();
    });
    
}]);
@@ -135,16 +135,30 @@
  'urls',
+ 'envOptions',
  functio
@@ -236,16 +236,28 @@
 es, urls
+, envOptions
 ) %7B%0A%0A  /
@@ -424,16 +424,18 @@
 // %7D);%0A%0A
+  
   $scope
@@ -451,223 +451,37 @@
 s = 
-%7B%0A    %22en%22: %7B%0A      %22title%22: %22English%22,%0A      %22languageCode%22: %22en%22,%0A      %22languageCodeMoment%22: %22en%22%0A    %7D,%0A    %22aa%22: %7B%0A      %22title%22: %22Elvish%22,%0A      %22languageCode%22: %22aa%22,%0A      %22languageCodeMoment%22: %22en%22%0A    %7D%0A  %7D
+envOptions.supportedLanguages
 ;%0A%0A 

make supported languages easier to handle