Home > Mobile >  Inserting laravel 8 translator inside HTML <img> tag
Inserting laravel 8 translator inside HTML <img> tag

Time:02-28

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?

CodePudding user response:

This will work

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

CodePudding user response:

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') }}">
  • Related