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?
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"? ;)
Thanks, -Derek (dww)
On Tue, Dec 23, 2008 at 11:36 AM, Derek Wright drupal@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
On Dec 23, 2008, at 3:07 PM, Gábor Hojtsy wrote:
t() did not improve in this regard at all.
Duly noted, thanks. Any objection to backporting these improved API docs to D5 to help avoid confusion? If not, I'll roll a patch and submit an issue.
No, there is no way, and it does throw the same warnings on core code, where the same applies.
Alas.
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").
Ahh, thanks for the reminder. My version of potx-cli is from a very old DRUPAL-5 branch checkout.
Thanks for all the info, -Derek (dww)
On Tue, Dec 23, 2008 at 6:15 PM, Derek Wright drupal@dwwright.net wrote:
On Dec 23, 2008, at 3:07 PM, Gábor Hojtsy wrote:
t() did not improve in this regard at all.
Duly noted, thanks. Any objection to backporting these improved API docs to D5 to help avoid confusion? If not, I'll roll a patch and submit an issue.
Fine with me. I keep committing API docs changes to D6 so that our code is better documented, not entirely sure about Niel, but I think he can be convinced.
Happy holidays!
Gábor