Reputation: 511
I am working with AngularJS and since yesterday I try to implement translations using 'angular.translate' of Pascal Precht. This works in general as following:
app.js
angular.module('app', ['ionic', 'config', 'pascalprecht.translate'])
.config(function ($translateProvider)
{
$translateProvider.translations("de",
{
"ERROR": "Keine Wiederholung möglich!",
});
$translateProvider.translations("en",
{
"ERROR": "No recurrence possible!",
});
$translateProvider.preferredLanguage("en");
})
Round.controller.js
$scope.save = function ()
{
if ($scope.round.adjusted)
{
if ($scope.round.variant.key === "HO")
{
$scope.$emit('toast', 'No recurrence possible!');
return;
}
}
My question is: What do I need to do in order to substitute the Code behind $scope.$emit
to some with 'angular.translate' using a variable?
Upvotes: 0
Views: 80
Reputation: 74
You need to inject $translate to your controller and use the $translate.instant function.
var errorText = $translate.instant('ERROR');
$scope.$emit('toast', errorText);
Upvotes: 2