Search code examples
javascriptangularjsionic-frameworkangular-translateionic-view

Angular-translate: how to translate Ionic directives?


THE QUESTION:

I am translating my Ionic app into several languages. I am using angular-translate that does a very good job.

However there are some compatibility issues using it with Ionic directives such as ion-view

EXAMPLE:

In these ways is working smoothly:

<h4> { 'EDIT_YOUR_INFO' | translate } </h4> 

simple usage as filter

<p ng-bind-html=" 'USERNAME' | translate "></p>

using ng-bind to avoid issues with foreign characters

THE ISSUE:

<h4> and <p> are HTML tags and there are no problem at all using angular-translate with them. Everything is working fine.

The problems are when have to translate Ionic directive, such as <ion-view>

<ion-view view-title="Edit Profile">

The words 'Edit Profile' will appear in the upper header bar. I need to translate also them. I have tried but it doesn't work.

<ion-view view-title="'PROFILE_EDIT' | translate">

THE QUESTION:

How can i translate Ionic directives?


Solution

  • You need to use {{ }} for expressions on normal attributes.

    <ion-view view-title="{{ 'PROFILE_EDIT' | translate }}">