Last active
February 13, 2017 10:47
-
-
Save matthewjackowski/4de23ecd9f4cdf977b61 to your computer and use it in GitHub Desktop.
Basic App Setup for Angular Translate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var translations = { | |
"All": "All", | |
"Active": "Active", | |
"Completed": "Completed", | |
"Clear_Completed": "Clear_Completed" | |
}; | |
var estranslations = {}; | |
app.config(['$translateProvider', function ($translateProvider) { | |
// add translation table | |
$translateProvider | |
.translations('en', translations) | |
.translations('es', estranslations) | |
.preferredLanguage('en'); | |
}]); | |
app.controller('TranslateController', ['$scope', '$translate', function ($scope, $translate) { | |
// expose translation via `$translate` service | |
$scope.changeLanguage = function (langKey) { | |
$translate.use(langKey); | |
$translate('Todo_Input').then(function (Todo_Input) { | |
$scope.Todo_Input = Todo_Input; | |
}); | |
$translate('All').then(function (All) { | |
$scope.All = All; | |
}); | |
$translate('Active').then(function (Active) { | |
$scope.Active = Active; | |
}); | |
$translate('Completed').then(function (Completed) { | |
$scope.Completed = Completed; | |
}); | |
$translate('Clear_Completed').then(function (Clear_Completed) { | |
$scope.Clear_Completed = Clear_Completed; | |
}); | |
}; | |
$translate('Todo_Input').then(function (Todo_Input) { | |
$scope.Todo_Input = Todo_Input; | |
}); | |
$translate('All').then(function (All) { | |
$scope.All = All; | |
}); | |
$translate('Active').then(function (Active) { | |
$scope.Active = Active; | |
}); | |
$translate('Completed').then(function (Completed) { | |
$scope.Completed = Completed; | |
}); | |
$translate('Clear_Completed').then(function (Clear_Completed) { | |
$scope.Clear_Completed = Clear_Completed; | |
}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment