The PO catalogue format itself does not restrict translations to be one-liners but you need to use proper markup:
#: example.php:2
msgid "__multi_line_example__"
msgstr ""
"One line\n"
"Two lines\n"
"Three lines\n"
Unluckily, the popular Poedit program does not make it easy: you can type actual new lines with the Enter key but they are silently discarded on save! You can insert new lines even with Poedit but you need to type a \n
escape sequence manually:
(No idea about what other graphical tools do.)
The string will be printed with echo, so the string should be valid HTML.
IMHO, accepting HTML code from translators is kind of risky. You give them too much power to break the app badly. It's normally safer to only accept plain text and escape it properly when injecting it in HTML context, e.g.:
<p><?php echo htmlspecialchars(_('msg_forgot_pw')); ?></p>
This also makes the string usable in non-HTML context (e.g., a plain text e-mail message).
My advice is that:
- The translatable string contains plain text
You add <br>
tags yourself when printing
<p><?php echo nl2br(htmlspecialchars(_('msg_forgot_pw'))); ?></p>
This is pretty lengthy so I suggest writing wrappers:
/**
* Fetches translation as HTML (block with line feeds)
*
* @param string $msg_id Message ID
* @return string HTML
*/
function p($msg_id){
return nl2br(htmlspecialchars(_($msg_id), ENT_COMPAT | ENT_HTML401, 'UTF-8'), false);
}
/**
* Fetches translation as HTML (single line)
*
* @param string $msg_id Message ID
* @return string HTML
*/
function l($msg_id){
return htmlspecialchars(_($msg_id), ENT_COMPAT | ENT_HTML401, 'UTF-8');
}
Edit: The answer to the updated question is "no, not with Poedit". You'll have to live with that or find another tool.