[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug with xgettext and PHP
From: |
Bruno Haible |
Subject: |
Re: Bug with xgettext and PHP |
Date: |
Thu, 24 Nov 2005 13:32:17 +0100 |
User-agent: |
KMail/1.5 |
Daniel Hahler wrote:
> with PHP, when you use the _() function for an index of an array, it gets
> extracted with xgettext, but only when you use literal indexes. Please see
> the example below. The expected result is to not have any of these three
> extracted.
> <?php echo _(\$a[1])._(\$a['2'])._(\$a[\"3\"])); ?>
Generally, inside a _(), xgettext expects to see one string and extracts
it. This is not 100% identical with the semantics of the programming
language, but is transparent enough so that you can play nice tricks
with it. Such as
_(false ? "literal string" : decrypt("encrypted literal string")).
So a change in this area would have benefits _and_ drawbacks.
There are several workarounds in your case: move the access to a
function, such as
function monthname(x) { return _(\$a[x]); }
- sorry if I didn't get the PHP syntax right - or assignment of the
index to a variable outside the _().
> I hope you consider fixing it.
No, it will not be fixed, because as said above, there are reasonable
use cases of lax syntax checking.
Bruno