0

I want to have my text translated and I am using poedit to translate my text. I am working in ZF2.

I do have my translation file (created with poedit) in place. And that is working. For example: in this view example the "Sign in" is translated.

(1) <a href="#">{{'Sign in' | trans}}</a>

No I want to add the login view with ng-include, like this:

(2) <div ng-include="'/account/login'"></div>

That works fine too, my login view is there.

But: none of the translations do work in this view. In the login view, this:

(3) <span>{{ 'Password' | trans }}</span>

is not translated. If I add that (3) code however directly after (1), the translation works.

My Question is: how can I ensure that the translations do work when I use a ng-include to add other views?

Hope my question makes sense and that someone knows what to do.

Thanks!

Sam
  • 16,435
  • 6
  • 55
  • 89
ProX
  • 297
  • 1
  • 3
  • 16

1 Answers1

0

I found a way to solve this.. I think one of the solution is for example:

<div ng-controller="LoginCtrl">
   <span>{{ Password }}</span>
</div>

and then on your LoginCtrl should look like this:

app.controller('LoginCtrl', ['$scope', '$translate', function ($scope, $translate) {
  // expose translation via `$translate` service
  $translate('Password').then(function (password) {
    $scope.Password = password;
  });
}]);

you may go to this article for more info http://angular-translate.github.io/docs/#/guide/03_using-translate-service#using-$translate-service_things-to-keep-in-mind