Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: HTML inside gettext function string

Tags:

html

php

gettext

I'm somewhat of confused. As far as I knew every text in a gettext function is used as msgid

So this one:

_("My long text that I <br> because I need to ")

should be:

#: htdocs/index.php:8
msgid "My long text that I <br> because I need to"
msgstr "Translation needs different <br> inside because russian is different"

I just can't find any documentation that gettext() or _() strips html tags out.

Should I be replacing it like this? And why?

sprintf(_("My long text that I %s because I need to "), '<br>')
like image 870
spankmaster79 Avatar asked Apr 26 '26 12:04

spankmaster79


1 Answers

Both would work okay, gettext does not string anything out of the messags. You might however want to not include HTML in translations to make translators life easier - it is easier to just translate string and don't have to care about HTML markup. Of course sometimes it is not really possible...

like image 77
Michal Čihař Avatar answered Apr 29 '26 02:04

Michal Čihař