angular-translator
translation tables for angular2

View the Project on GitHub tflori/angular-translator

Build Status Coverage Status npm version

TranslateComponent

This is a angular2 component for the selector [translate]. It is a component and has a template that is not keeping your html code inside of the element -> the element should be empty.

Example

<p translate="LICENSE">Loading... this text will be replaced by the translated value</p>

Parameters

To dynamize your translation you can add parameters in the attribute translateParams. Keep in minde that it will be a string if you don’t add brackets around the parameter and translation only accepts objects.

<p translate="TODAY" [translateParams]="{date: new Date()}"></p> 

Variable Translation Key

You can make the key variable in two different ways.

By adding brackets:

<p [translate]="'SOME_'+key"></p>

By using variable inside attribute:

<p translate="SOME_{{ key }}"></p>

Module

You can use a specific module by adding translatorModule attribute - you can make it dynamic the same way as parameters. If this is empty the provided Translator will be used. You can overwrite the provided translator in the component (described in section Modules).

<p translate="TITLE" translatorModule="admin"></p>