Christopher Cook
Christopher Cook

Reputation: 830

Using Translate pipe in Ionic 2?

Does anyone have a working example of the Translate pipe for Ionic 2?

console.log("trans: "+this.trans.translate('Location')); // works fine in code

According to http://ionicframework.com/docs/v2/utils/translation/ the template syntax should be:

<h2>{{'My example key' | translate}}</h2>

For me this results in the following JS error:

EXCEPTION: Cannot find pipe 'translate'. in [null]BrowserDomAdapter.logError @ app.bundle.js:36432

Upvotes: 1

Views: 2841

Answers (1)

tyftler
tyftler

Reputation: 419

Import and insert TranslatePipe in your @Page like so:

import {Page, TranslatePipe} from 'ionic/ionic';

@Page({
  templateUrl: 'build/pages/home/home.html',
  pipes: [TranslatePipe]
})

See: http://www.joshmorony.com/how-to-use-pipes-to-manipulate-data-in-ionic-2/

Upvotes: 3

Related Questions