[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
xgettext PHP parsing bug with associative arrays
From: |
Robert Vock |
Subject: |
xgettext PHP parsing bug with associative arrays |
Date: |
Fri, 16 Mar 2007 15:37:22 +0100 |
User-agent: |
Thunderbird 1.5.0.10 (Windows/20070221) |
Hello there,
we are just switching to gettext in our PHP project and I noticed a
bug in xgettext, when extracting from PHP files with associative
arrays:
<?php
$array = array( 'key' => 'value' );
echo gettext( $array['key'] );
?>
xgettext extracts the msgid "key" from this code example.
The resulting po file will contain:
msgid "key"
msgstr ""
I think, to fix this bug, the x-php.c must also parse the square
brackets and ignore the inner contents. (Just as it does with the
parentheses)
Workarounds within PHP exist:
1. workaround:
use a dummy function to prevent the parsing
<?php
function fixXgettext( $str ) { return $str; }
$array = array( 'key' => 'value' );
echo gettext( fixXgettext( $array['key'] ) );
?>
2. workaround:
use a temporary variable
<?php
$array = array( 'key' => 'value' );
$str = $array['key'];
echo gettext( $str );
?>
Greetings,
Robert Vock
PS:
Is there a bugtracker for GNU projects? I did not find one and I could
not find anyone who had the same problem...
- xgettext PHP parsing bug with associative arrays,
Robert Vock <=