HTML-теги в переводе Laravel - PullRequest
       9

HTML-теги в переводе Laravel

0 голосов
/ 22 февраля 2019

Я пытаюсь перевести строку, содержащую теги HTML, но лезвие Laravel возвращает меня в виде обычного текста.

{{ _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%') }}

результат:

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!

Я используюследующий пакет Laravel.

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

Ответы [ 2 ]

0 голосов
/ 22 февраля 2019

Для этого вы можете попробовать два варианта:

{!! _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%'))!!}

Оба должны нормально работать для вас.

0 голосов
/ 22 февраля 2019

вы можете отобразить html-теги следующим образом:

{!! 'this text will be <b>bold</b>.' !!}

Вывод: этот текст будет полужирным .

Laravel использует {{ }} для экранирования тегов, чтобы предотвратить атаки XSS.

Но в любом случае вам нужно визуализировать html-теги внутри переменной, вы можете использовать {!! !!}

...