Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Ionic angular translate not working

Im using ionic 2 and went through this document:

http://ionicframework.com/docs/resources/ng2-translate/

I made all the changes needed for translation to work. However, when I write this in an html file:

{{ 'HELLO' | translate }}   

In the page I see

HELLO   

This, even thought I have a file at /assets/i18n/en.json which contains:

{
    "HELLO": "Hello there"
}

In app.ts I added these imports:

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

And then after the imports I have this:

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

And also this in @NgModule->import's array:

TranslateModule.forRoot({
  loader: {
    provide: TranslateLoader,
    useFactory: (createTranslateLoader),
    deps: [Http]
  }
})      

What I realized is that my app had since before this import:

import { HttpModule } from '@angular/http';

Im not sure why I imported that but if I remove it then the app breaks in other places. Is that the problem? Importing angular/http twice with two different names? Tried to only use the original one, but in the export function it doesn't like the argument

http: HttpModule

insead of the one in the documentation

http: Http

Can I see if the en.json has been loaded? Or what is the problem here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can see en.json using Inspector Web (F12). Do you use these methods somewhere in your code source?

this.translate.setDefaultLang('en');
this.translate.use('en');

In the view, you see only 'HELLO' because (I think so) you did not configure the language to use.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!