-
Notifications
You must be signed in to change notification settings - Fork 4
Ng2 translate
Here is a really easy tutorial for using NG2. Link
-
Add to imports
import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
-
Add e translate service to your constructor
` private translate: TranslateService`
-
In your
@component
section add a new pipe
pipes: [TranslatePipe]
-
You can use the pipe to translate in your .html-file
{{ "key" | translate }}
-
To get a translation in your .ts-file use
this.translate.instant("key");
-
Navigate to the
www/assets/i18n/
and create a JSON-file named after the language you want to translate to. -
You can copy the content form an other JSON-file to your new file, so you have already all the variabels you want to translate.
-
Translate the words on the right into the new language.
-
Go to app/components/setting.ts and add the new language to the changeLanguage(lang) function.
-
Add the Language in the setting.html file.