我目前正在使用带有 POEdit 的 gettext 翻译我的 PHP 应用程序。由于我尊重源代码中的打印边距,因此我习惯于编写这样的字符串:
print $this->translate("A long string of text
that needs to follow the print margin and since
php outputs whitespaces for every break line I do
my sites renders correctly.");
但是,在 POEdit 中,正如预期的那样,换行符不会转义为空格。
A long string of text\n
that needs to follow the print margin and since\n
php outputs whitespaces for every break line I do\n
my websites render correctly.\n
我知道一种方法是在更改源代码中的行时关闭字符串,如下所示:
print $this->translate("A long string of text " .
"that needs to follow the print margin and since " .
"php outputs whitespaces for every break line I do " .
"my sites renders correctly. ");
但是当文本需要更改并且打印边距仍然受到尊重时,这对我来说不是一种可扩展的方法,除非 netbeans(我使用的 IDE)可以像 java 中的 eclipse 一样自动为我做到这一点。
所以总而言之,有没有办法告诉 POEdit 解析器将换行符转义为首选项中的空格?
我知道即使换行符没有被转义,字符串仍然是可翻译的,我问这个是为了让我的 traductor(有时甚至是客户/用户)避免混淆,以为他在 POEdit 中翻译时需要复制换行符。