title: How to use Angular 2 Translate service pipe in code?
body: <p>Here is the thing... I'm using an angular 4 template in my app, and this has a good working translate service. 
  The problem is that I don't know how to use that pipe in code.</p>
  
  <p>In HTML just put <code>&lt;span&gt;{{ this.variable | traslate }}&lt;/span&gt;</code> and then, 
  the service go to some JSON files to find the text and translate.</p>
  
  <p>Here is the code in my component.ts</p>
  
  <pre><code>const SMALL_WIDTH_BREAKPOINT = 960;
  @Component({
    selector: 'app-mycomponent',
    templateUrl: './mycomponent.component.html',
    styleUrls: ['./mycomponent.component.scss']
  })
  
  export class TrackingComponent implements OnInit { 
    currentLang = 'es';
    private mediaMatcher: MediaQueryList = matchMedia(`(max-width: 
    ${SMALL_WIDTH_BREAKPOINT}px)`);
    constructor(
      public translate: TranslateService,
      zone: NgZone,
      private router: Router,
    ) {
      const browserLang: string = translate.getBrowserLang();
        translate.use(browserLang.match(/en|es/) ? browserLang : 'es');
        this.mediaMatcher.addListener(mql =&gt; zone.run(() =&gt; {
          this.mediaMatcher = mql;
        }));
        translate.use(this.currentLang);
    }
  
    ngOnInit() { }
  
    myFunction(msg: string) : {
      const translatedText = msg; // HERE IS WHERE I WANT TO USE THE TRANSLATE SERVICE BUT I DON'T KNOW HOW TO CALL IT
      alert(translatedText );
    }
  
  }
  </code></pre>
  
  <p>Yes, I put all the needed things in the module, because it works in HTML... but I don't know how to call it in the code.</p>
  
  <p>I was searching how to solve my problem and I found This:</p>
  
  <pre><code> let translatedText = new TranslatePipe().transform(msg);
  
   but the `TranslatePipe` does not work. 
  </code></pre>
  
  <p>Anyone knows how to call it?</p>