Search code examples
phplaravellaravel-5laravel-bladegettext

HTML tags in translation Laravel


I'm trying to translate a string that contains HTML tags, but Laravel blade returns me in plain text.

{{ _i('The <b>%s</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive %s of their earnings for life!', 'gano.com', '20%') }}

result:

The <b>gano.com</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive 20% of their earnings for life!

I'm using the following Laravel package.

https://github.com/Belphemur/laravel-gettext


Solution

  • You can try below two options for this:

    {!! _i('The <b>%s</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive %s of their earnings for life!', 'gano.com', '20%') !!}
    
    {!!html_entity_decode(_i('The <b>%s</b> referral program is a great way to spread the word of this great service and to earn even more money with your short links! Refer friends and receive %s of their earnings for life!', 'gano.com', '20%'))!!}
    

    Both should work fine for you.