PHP usage


Let's use our example :

require_once "GetText.php";

// initialiase GetText package
GetText::init();

// add the translation domain we wrote files for
GetText::addDomain('mydomain', '/path/to/your/translation_root');

// set the language to use 
GetText::setLanguage('fr_FR');

// translate following sentence
echo GetText::gettext('Simple test');

This should echo "Une petite phrase en français".

If you have php gettext support installed but for some reason prefers to use the GetText parser, replace GetText::init() with the following line :

GetText::init(GETTEXT_PHP);

The second argument of addDomain() is the path to the translation root, if no path is given, GetText will look into "./locale".