HTML 翻译中的标签 Laravel

HTML tags in translation Laravel

我正在尝试翻译一个包含 HTML 标签的字符串,但是 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%') }}

结果:

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

您可以像这样渲染 html 标签:

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

输出:此文本将是 粗体

Laravel 使用 {{ }} 转义标签以防止 XSS 攻击。

但是无论如何你需要渲染变量内部的html标签,你可以使用{!! !!}

您可以尝试以下两种选择:

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

两者都适合您。