bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About a PHP variable in gettext!


From: Bruno Haible
Subject: Re: About a PHP variable in gettext!
Date: Mon, 2 Feb 2004 12:39:50 +0100
User-agent: KMail/1.5

zhang ayla wrote:
> I encounter a problem about the gettext .
> when i add a PHP variable to the string gettext("how are you $var ");
> Then i run the $ xgettext x.php,found the msgid  have not  result in .po
> file like this msgid ''how are you $var "
>      msgstr ""
> can you tell me why?

Hi,

You have to understand that 'gettext()' is a PHP function that performs a
lookup in a message catalog, and the way you wrote it, $var is substituted
_before_ the lookup in the message catalog. This doesn't work because you
cannot know all possible values of $var in advance. The solution is to
substitute $var _after_ the message catalog lookup. Like this:

  printf (gettext ("how are you %s "), "$var")

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]