|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52671 PHP gettext not uniformying CRLF newlines
Submitted: 2010-08-22 18:24 UTC Modified: -
Avg. Score:4.9 ± 0.3
Reproduced:11 of 11 (100.0%)
Same Version:8 (72.7%)
Same OS:10 (90.9%)
From: adrien dot morel at informance dot info Assigned:
Status: Open Package: Gettext related
PHP Version: 5.2.14 OS: Win32
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-08-22 18:24 UTC] adrien dot morel at informance dot info
I already started a dicussion about that on but it turned out that it may be a PHP gettext implementation issue.

It's a problem I encounter while using the PHP gettext functions on PHP files with CRLF newlines (Windows format). See the test script below and its comment for an explanation.

The problem is that xgettext, from GNU, following the recommandations of the Unicode consortium ( ), changes every CRLF for simple LF when extracting strings from the PHP file. So if a PHP file contains CRLF newlines, xgettext will turn them into LF when writing the catalog. But PHP gettext functions will still look for CRLF newlines in the catalog when finding a string with CRLF newline. The matching msgid won't be found then.

In short, parsing a Windows PHP file with xgettext, and then running PHP gettext on this file will not work, the translation will not be found, because the comparison between strings will fail.

Test script:
// If this text is saved in a Unix-style newlines format (LF)
// it will work. In Windows-style (CRLF), it won't, because the
// linebreak in the string will be encoded as CRLF, so it won't
// be found in the catalog, which universally encode newlines as LF.
$s = gettext(
My name is Foo Bar."

Expected result:
Regardless of the newline encoding of the file, the above string should be found in the catalog's msgids, which always use the LF newline.

Actual result:
For the moment, on Windows-style files, strings with a linebreak inside are not translated even though their translation is available in the catalog.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 13:01:23 2020 UTC