views:

18

answers:

1

I am currently translating my PHP application using gettext with POEdit. Since I respect the print margin in my source code, I was used to writing strings like that:

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.");

However, in POEdit, as expected, the linebreaks are not escaped to whitespaces.

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

I know one approach would be to close the strings when changing lines in the source code like that:

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. ");

But it is not an approach that is extensible for me when texts need to change and print margin still respected, unless netbeans (the IDE I use) can do that for me automatically just like eclipse in java.

So in conclusion, is there a way to tell the POEdit parser to escape linebreaks as whitespaces in the preferences?

I know that the strings are still translatable even though linebreaks are not escaped, I'm asking this so my traductor (sometimes even the customer/user) will avoid confusion into thinking he needs to duplicate the linebreaks while he translates in POEdit.

A: 

You have to make sure that your using the right line breaks in your script and your app

 LF:    Line Feed, U+000A
 FF:    Form Feed, U+000C
 CR:    Carriage Return, U+000D
 CR+LF: CR (U+000D) followed by LF (U+000A)
 NEL:   Next Line, U+0085
 LS:    Line Separator, U+2028
 PS:    Paragraph Separator, U+2029

Within Windows systems (ms-dos) there line feed is CR+LF, And within "Unix-like" systems its LF adn 8Bit commodore's its a CR

You have to make sure that the source location contains the same type of feeds to your edit location.

Your server handles its line feeds different to the host that the editor is running on, just double check this and develope some means of auto replacing the Unicode chars depending on your OS


As you say that your "translating my PHP application using gettext with POEdit", i would create a script to go threw all your files via shell/doss/php and auto convert the character codes to the type of system your running on.

so if your working on Windows then you would search for all chars that are U+000A and replace with U+000DU+000A

RobertPitt
I don't have line breaks issues across OSes since I make sure to use Unix-like line breaks within my source code (or maybe I did not understand clearly your statement). I thought there would be an easy way to interpret line feeds as whitespaces in the xgettext parser command. Is this possible?
Steven Rosato