Skip to content

Instantly share code, notes, and snippets.

@matthewjackowski
Last active February 13, 2017 10:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewjackowski/4de23ecd9f4cdf977b61 to your computer and use it in GitHub Desktop.
Save matthewjackowski/4de23ecd9f4cdf977b61 to your computer and use it in GitHub Desktop.
Basic App Setup for Angular Translate
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