0

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 ??

2 Answers 2

1

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'); }); 

Live demo

Sign up to request clarification or add additional context in comments.

1 Comment

Have you seen the plunkr demo? Is there any difference with your code?
1

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']; }); 


imgur

1 Comment

can you provide me a plunker @mikko viitala

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.