Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda