0.2.5 • Published 5 years ago

cw-translate v0.2.5

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
5 years ago

cw-translate

Services und Directiven für Übersetzungen.

Directives

Services

Benutzung

Laden und Konfiguration

Innerhalb des Haupt-Moduls muß das CwTranslateModule importiert werden:

import { CwTranslateModule } from 'cw-translate';

@NgModule({
  ...
  imports: [
    CwTranslateModule.forRoot(),
  ]
  ...
})

Anschließend muß das Modul konfiguriert werden. Dies geschieht am Besten innerhalb eines APP_INITIALIZER:

import { APP_INITIALIZER } from '@angular/core';

import { ConfigService as TranslatorConfigService } from 'cw-translate';

export function initApp(translatorConfig: TranslatorConfigService) {
  return (): Promise<void> => {
    return translatorConfig.consumeConfiguration({
      appKey: 'myc',
      debug: true,
      language: 'de',
      prefix: 'https://cwws-dev.cambio.intra/cwapi/resource/text/cwmobile/common,myc.',
    });
  };
}

export const appInitializerProvider = {
  provide: APP_INITIALIZER,
  useFactory: initApp,
  deps: [
    TranslatorConfigService,
  ],
  multi: true,
};

Testen

Zum Starten des Test-Server:

ng test

Mit codecoverage-Bericht:

ng test --code-coverage

Das sollte einen Browser (Standardmäßig Chrome) starten. Wenn nicht, einfach in einem Browser localhost:9876 öffnen.

Die codecoverage läßt sich dann betrachten indem man die Datei coverage/cw-translate/index.html in einem Browser öffnet.

0.2.5

5 years ago

0.2.1

6 years ago