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

192
Visualizações
Using ngx-translate to display images

I would like to use ngx-translate inside my Angular app to display a language-specific image. In my case its a Logo which is displayed in different languages and styles depending on the used language.

I did already tried with

        <img style="width: 100px" [attr.src]="'branding.logo' | translate" alt="" class="src" />

Where branding.logo refers to a URL of the particular logo in the web.

But Chrome displays, that it couldn't find the requested ressource at: 'https://localhost:8100/branding.logo'.

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

[attr.src]="'branding.logo' | translate" is causing the literal branding.logo to be used. If you want to get the value from that then it should be [attr.src]="branding.logo" however that will not support translate.

In order to achieve a translation, you probably want to map it as branding.logoMapByLocale and then use the current locale to get the actual value.

Your code will look something like this:

(How to get locale from this question)

import { LOCALE_ID, Inject } from '@angular/core';

...

constructor(
  @Inject(LOCALE_ID) public locale: string
) {

  this.logoMapByLocale = {
    'en': "https://some/path/en.png",
    'fr': "https://some/path/fr.png",
}
about 4 years ago · Juan Pablo Isaza 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