How to translate inside ts instead in template using ngx-translate?

Hi everyone,

I’ve set up everything following this:

And it’s working properly when it comes to translate in templates, but inside my providers I’ve got a loader that are shown meanwhile data comes from an API Rest.

These loaders also contain an string like “Loading…”, so I need to translate them as well but I couldn’t find how to do it.


export class ContenidosService {

  loader:any = null;

  constructor(public http: Http, public navCtrl: NavController, public loadingController: LoadingController) {
    let loader = this.loadingController.create({
      content: "Loading..."
    this.loader = loader;

Any help would be appreciated.

Here you can read all about ngx-translate and Ionic:

@LoLStats I’ve been looking for any help overthere but I didn’t find anything related with my doubt.

What you have to do is this

  value => {
    // value is our translated string
    let loadingContent = value; 
// Open your loading controller here and the value is your text you want to display

Thank you so much @LoLStats, I was trying to use translatePipe.transform but I guess this way is better.

1 Like