Translation Angular 2 using ngx-translate? -


i have configuration , setting following instructions.

app.module.ts

import {  http } '@angular/http'; import {translatemodule, translatestaticloader, translateloader, translateservice } 'ng2-translate';  imports: [     browsermodule,     httpmodule,     translatemodule.forroot({       provide: translateloader,       usefactory: (http: http) => new translatestaticloader(http, '/assets/i18n', '.json'),       deps: [http]     }) ] 

component:

import {translateservice,translatepipe } 'ng2-translate';  constructor( private activateroute: activatedroute, public translate: translateservice) {     translate.addlangs(['en']);     translate.setdefaultlang('en');    } 

and view component:

{{ 'intro' | translate }} 

this library not work me, alwsays displays key of word intro instead value translations.

there not errors in console. why ngx-translate not work or wrong.

if you're still on angular <4.3, please use http @angular/http http-loader@0.1.0.

so running

npm install @ngx-translate/http-loader@0.1.0 --save  

did trick me

source: ngx-translate/core


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -