[translations] Use of variables in t()

Gábor Hojtsy gabor at hojtsy.hu
Tue Dec 23 14:07:34 UTC 2008


On Tue, Dec 23, 2008 at 11:36 AM, Derek Wright <drupal at dwwright.net> wrote:
> In the D6 API docs for t(), it says:
>
> http://api.drupal.org/api/function/t/6
>> The only case in which variables can be passed safely through t() is
>> when code-based versions of the same strings will be passed through
>> t() (or otherwise extracted) elsewhere.
> ...
>
> I have a few questions about this:
>
> A) The D5 docs don't say the same thing.  However, this seems like the
> sort of thing that would be equally true of t() in both branches,
> unrelated to all the i18n changes in D6.  Can someone confirm that t()
> didn't change in D6 to allow for this edge-case, but only that the API
> docs improved?

t() did not improve in this regard at all.

> B) I seem to have an example in one of my contribs where this edge
> case is being hit.  Once I add t($foo) to my code (where all possible
> values of $foo are listed via t() around string literals elsewhere in
> the code), potx.php starts throwing error messages about "Invalid
> marker content ...".  Is there anything I can do to tell potx "yes, I
> know, but this is that edge case where it's ok, please shut up
> again"? ;)

No, there is no way, and it does throw the same warnings on core code,
where the same applies. By the way, I'd advise you to upgrade your
potx, since later versions give better warnings and even link to more
docs where you can read details (and do not say criptic things like
"marker error").

Gábor


More information about the translations mailing list