0

I have looked for answers over Google and Stackoverflow, but didn't find a solution.

I followed instructions from the website

My steps:

1) Created an Angular 4 project using ng new NGXTest.

2)Inside the project folder, executed:

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

3) Added imports:

import { HttpModule, Http } from '@angular/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';`

4) Added to app.module.ts next line:

export function createTranslateLoader(http: Http) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

And here is when the problem starts.

Error in Visual Studio Code, Web executing, and in Git terminal

And if I continue with the tutorial, i get also other errors in Git terminal.

DJo
  • 2,133
  • 4
  • 30
  • 46
URKA
  • 1
  • 3

2 Answers2

0

Try this:

@NgModule({
    imports: [
        BrowserModule,
        HttpModule,
        TranslateModule.forRoot({ 
          provide: TranslateLoader,
          useFactory: (http: Http) => new TranslateStaticLoader(http, './assets/i18n', '.json'),
          deps: [Http]
        })
    ],
    exports: [BrowserModule, HttpModule, TranslateModule],
})

Suppose to work.

Avnesh Shakya
  • 3,828
  • 2
  • 23
  • 31
  • Thanks very much, yesterday I solved the problem, I explain my mistake down. I gave you a +1 vote, but I dont have reputation yet :D – URKA Aug 02 '17 at 11:45
0

I already solved the problem, and I will explain my mistake.

I followed tutorial from the official website: http://www.ngx-translate.com/

But I didn't do it properly.

There are 2 libraries, which must be installed: -core -http-loader

I installed both but didn't include code lines for http-loader.

Following instructions properly is enough, and is not difficult.

Thanks for all the help. And I am sorry for making you lose time.

URKA
  • 1
  • 3