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

190
Views
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 answers
Answer question

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 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!