Reputation: 155
i am using https://angular-translate.github.io/ module for translation
my key array is
$scope.array = [
"full_name",
"email",
"phone_no"
];
and my translation for that is
$translateProvider.translations('en', {
full_name:'full name',
email:'email',
phone_no:'phone no'
});
and have code like this
<div ng-repeat="item in array">
{{item | translate}}
</div>
but i can't get translation. can anyone help to do proper way ??
Upvotes: 0
Views: 64
Reputation: 8394
This should do it
angular.module('app', ['pascalprecht.translate'])
.config(function($translateProvider) {
$translateProvider.translations('en', {
full_name: 'Full name',
email: 'Email address',
phone_no: 'Phone number'
});
$translateProvider.preferredLanguage('en');
$translateProvider.fallbackLanguage(['en']);
})
.controller('MainCtrl', function($scope) {
$scope.array = ['full_name','email','phone_no'];
});
Upvotes: 1
Reputation: 20689
Have you set the preferred language in the configuration? If you don't do so, the 'en'
translations won't be applied.
.config(function($translateProvider) {
$translateProvider.translations('en', {
/* ... */
});
$translateProvider.preferredLanguage('en');
});
Upvotes: 1