Net Possibility Multiplier

    ng2-translator
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.1 • Public • Published

    ng2-translator

    NPM version Build Status Coverage Status Dependency Status devDependency Status GitHub license Gitter

    ng2-translator is a simple translation service and directive that manages multiple languages

    import { Component } from '@angular/core';
    import { Translator, TranslatorComponent } from 'ng2-translator';
     
    @Component({
      selector: 'app',
      template: `
          <h2><wf-translate id="HEADER"></wf-translate></h2>
          <button (click)="changeLang('de')">In German, please!</button>
        `,
      directives: [TranslatorComponent],
      providers: [Translator]
    })
    export class AppComponent {
      constructor (private translator: Translator){}
     
      public changeLang(lang: string) {
        this.translator.setLanguage("de");
      }
      
      private initTranslator() {
        this.translator.setAvailableLanguages(["en", "de"]);
        this.translator.setTranslation("en", { HEADER: "Headline" });
        this.translator.setTranslation("de", { HEADER: "Überschrift" });
        this.translator.guessLanguage();
      }
    }

    CDN

    The module should be available via unpkg at https://unpkg.com/ng2-translator

    No guarantees for uptime or anything like that, though.

    API

    The module can be required as a CommonJS module. For usage details, read the documentation.

    Keywords

    none

    Install

    npm i ng2-translator

    DownloadsWeekly Downloads

    2

    Version

    1.1.1

    License

    MIT

    Last publish

    Collaborators

    • dbartholomae