views:

347

answers:

2

Hello,

How does gettext translate string variables? It doesn't seem to want to do it.. lets say I have $sentence = "Hello World"; and then I want to echo ($sentence); ... how can I do that so that I can translate what's inside $sentence in Poedit?I can use -> echo sprintf(("%s test"), $sentence) and this will print "Hello World test" in the browser but it will appear as "%s test" in Poedit and I won't get the translated version of Hello World inside of Poedit. So how can I use string variables inside Poedit? Thanks!

+2  A: 

You just must not have string variables. You should do e.g.

$sentance = _('Hello world');

The other way is to use some king of parser, which will be able to find your hello world strings and finally output somewhere

$fakie = _('Hello World');

This output should be stored in some file, which will then be pickedup by poedit and translated. For showing the translation you can than use

$myTranslation = _($sentance);

We used this conversion process for javascript files and smarty templates.

gregor
Thank you very much, this is exactly what I needed
Kentor
A: 

There is detailed information available in http://us2.php.net/manual/en/book.gettext.php.

Spike