Search code examples
angulartypescriptionic2ionic3

Angular 4 - ionic 3 translation of text inside '.ts' file


I want to know how translate text in '.ts' file
basically it's a loading text

showLoader() { 
this.loading = this.loadingCtrl.create({
  content: 'Loading...'
});
this.loading.present();

  }

what I need is to text "Loading..." translated to "Chargement..." When language is set to french
thanks


Solution

  • You can do it like below:

    Note: I extracted this from my working code base.So please adjust as you wish. If you need further help please let me know.

    presentLoader(): Loading {
        this.translate.get('Please_wait').subscribe(res => {
          this.content = res;
        });
        let loader = this.loadingCtrl.create({
          content: this.content
        });
        loader.present();
        return loader;
      }