I have all configuration and setting following instructions.
app.module.ts
import { Http } from '@angular/http';
import {TranslateModule, TranslateStaticLoader, TranslateLoader, TranslateService } from 'ng2-translate';
imports: [
BrowserModule,
HttpModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
deps: [Http]
})
]
Component:
import {TranslateService,TranslatePipe } from 'ng2-translate';
constructor( private activateRoute: ActivatedRoute, public translate: TranslateService) {
translate.addLangs(['en']);
translate.setDefaultLang('en');
}
And view component:
{{ 'Intro' | translate }}
This library does not work for me, it alwsays displays key of word Intro
instead value translations.
There are not any errors in console. Why ngx-translate
does not work or what I do wrong.
en.json
file insidei18n
folder and listIntro
in that file? – Nehal