これが私がそれを行う方法です。翻訳するフレーズは
By using this website, you accept the <a>Terms of Use</a>.
次に、フレーズがローカライズされた後にリンクを置き換えます。
$str = _('By using this website, you accept the <a>Terms of Use</a>.');
$str = preg_replace('#<a>(.*?)</a>#', '<a href="' . $dir . '/tos/">$1</a>', $str);
もちろん、 and は、あなたと翻訳者にとって意味のあるものに置き換えることができ<a>
ます</a>
。考えてみると、翻訳者が (意図的であろうとなかろうと) HTML を台無しにしないように出力をエスケープする必要があるため、おそらく次のようなものを使用します。
$str = htmlspecialchars(_('By using this website, you accept the [tos_link]Terms of Use[/tos_link].'));
$str = preg_replace('#\\[tos_link\\](.*?)\\[/tos_link\\]#', '<a href="' . $dir . '/tos/">$1</a>', $str);