title: How to translate Typescript strings in a Angular 2 app?
body: <p>I know of two major platforms for Angular 2 i18n: <a href="https://angular.io/docs/ts/latest/cookbook/i18n.html" rel="nofollow noreferrer">The official way</a>, and <a href="https://github.com/ocombe/ng2-translate" rel="nofollow noreferrer">ng2-translate</a>. I am much more inclined to use what the official docs recommend. For me it's very clear how to translate the HTML strings. But there is one thing I didn't get yet: How do I translate the Typescript strings?</p>
  
  <p>For example, I have the following component that uses the built-in i18n solution:</p>
  
  <pre><code>import { Component } from '@angular/core';
  
  @Component({
      moduleId: module.id,
      selector: 'hello',
      template: `
          &lt;h1 i18n&gt;Hello {{name}}!&lt;/h1&gt;
          &lt;button (click)="notify()"&gt;&lt;/button&gt;
      `
  })
  export class HelloComponent {
  
      private name = 'John Doe';
  
      notify() {
          /* How do I translate this? */
          alert(`Hello ${this.name}!`);
      }
  }
  </code></pre>
  
  <p>The string placed in the HTML will be translated. But how do I translate the string shown in the alert? If there is not a native way, what would be the recommended way to accomplish this?</p>