When using class constants, like:

class Foo {
  const X = 'bar';
  }

$baz = t(Foo::X);

potx chokes on 'Foo::X', not understanding it as a string. With PHP5 becoming mandatory for newer Drupal versions, this seems poised to happen more and more often.

t() itself, obviously, has no problem with the strings, so a temporary workaround is to add the strings to the .po file by hand.

Comments

gábor hojtsy’s picture

Status: Active » Closed (works as designed)

potx only supports static text by design. It does not support regular constants either.

fgm’s picture

So what is the recommended way to localize code using constants ?

Do you think one can really advocate the use of in-code hardcoded text as a recommended practice against defined constants ?

gábor hojtsy’s picture

fgm: Well, our current practice is text inlining. Feel free to come up with a patch against potx which recognizes the strings in t(), st(), $t(), format_plural() and so on in the form of constants as well, and then discuss.

Ps. note that I am not against the use of named constants, but I am not into implementing it myself.