Reputation: 830
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
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