: https://zargony.com/2008/01/24/links-in-gettext-translated-strings.
{curly brackets} . :
_("Please click {here} or {here}")
linkify, .
linkify(
_("Please click {here} or {here}"),
"</a>",
"<a href='www.example1.com'>",
"<a href='www.example2.com'>"
)
Definition in PHP:
function linkify($string, $closingTag) {
$arguments = func_get_args();
return preg_replace_callback(
'/{(.*?)}/',
function($matches) use ($arguments, $closingTag) {
static $i = 1;
$i++;
return $arguments[$i] . $matches[1] . $closingTag;
},
$string
);
}
PS: You can also easily replace {} for [], as I noticed that in curly brackets in POEdit they give warnings to translators and recommend not translating them.
source
share