gettext: Long Lines
1
1 15.5.18.8 How To Grok with Long Lines
1 .....................................
1
1 The necessity of long messages can often lead to a cumbersome or
1 unreadable coding style. Perl has several options that may prevent you
1 from writing unreadable code, and ‘xgettext’ does its best to do
1 likewise. This is where the dot operator (the string concatenation
1 operator) may come in handy:
1
1 print gettext ("This is a very long"
1 . " message that is still"
1 . " readable, because"
1 . " it is split into"
1 . " multiple lines.\n");
1
1 Perl is smart enough to concatenate these constant string fragments
1 into one long string at compile time, and so is ‘xgettext’. You will
1 only find one long message in the resulting POT file.
1
1 Note that the future Perl 6 will probably use the underscore (‘_’) as
1 the string concatenation operator, and the dot (‘.’) for dereferencing.
1 This new syntax is not yet supported by ‘xgettext’.
1
1 If embedded newline characters are not an issue, or even desired, you
1 may also insert newline characters inside quoted strings wherever you
1 feel like it:
1
1 print gettext ("<em>In HTML output
1 embedded newlines are generally no
1 problem, since adjacent whitespace
1 is always rendered into a single
1 space character.</em>");
1
1 You may also consider to use here documents:
1
1 print gettext <<EOF;
1 <em>In HTML output
1 embedded newlines are generally no
1 problem, since adjacent whitespace
1 is always rendered into a single
1 space character.</em>
1 EOF
1
1 Please do not forget that the line breaks are real, i.e. they
1 translate into newline characters that will consequently show up in the
1 resulting POT file.
1