Abdullah
Abdullah

Reputation: 1

Inserting laravel 8 translator inside HTML <img> tag

I have two versions of profile page. All are images and I want to insert @lang() so I can fetch the images belonging to the current language. Every time I make it, an error of syntax error, unexpected identifier "translator", expecting ")" appears.

<img src="{{ asset('home/theme/img/about/@lang('auth.profile-ar')/01.jpg') }}">

Can someone tell how the right way to do it?

Upvotes: 0

Views: 280

Answers (2)

Ayman Elmalah
Ayman Elmalah

Reputation: 331

This will work

<img src="{{ asset('home/theme/img/about/'.__('auth.profile-ar').'/01.jpg') }}">

Upvotes: 1

Moshe Katz
Moshe Katz

Reputation: 16883

You cannot use the @lang blade directive (or any other blade directive) inside a string like that.

Use the translation function __() like this instead:

<img src="{{ asset('home/theme/img/about/'.__('auth.profile-ar').'/01.jpg') }}">

Upvotes: 0

Related Questions