Public Member Functions | |
setLanguage ($langCode) | |
addDomain ($domain, $path=false) | |
gettext ($key) | |
setVar ($key, $value) | |
setVars ($hash) | |
reset () | |
Static Public Member Functions | |
& | _support ($set=false) |
init ($managerType=GETTEXT_NATIVE) |
This class allows gettext usage with php even if the gettext support is not compiled in php.
The developper can choose between the GETTEXT_NATIVE support and the GETTEXT_PHP support on initialisation. If native is not supported, the system will fall back to PHP support.
On both systems, this package add a variable interpolation system so you can translate entire dynamic sentences in stead of peace of sentences.
Small example without pear error lookup :
<?php require_once "GetText.php";
GetText::init(); GetText::setLanguage('fr_Fr'); // may throw GetText_Error GetText::addDomain('myAppDomain'); // may throw GetText_Error GetText::setVar('login', $login); GetText::setVar('name', $name);
// may throw GetText_Error echo GetText::gettext('Welcome ${name}, you\'re connected with login ${login}');
// should echo something like : // // "Bienvenue Jean-Claude, vous êtes connecté en tant qu'utilisateur jcaccount" // // or if fr_FR translation does not exists // // "Welcome Jean-Claude, you're connected with login jcaccount"
?>
A gettext mini-howto should be provided with this package, if you're new to gettext usage, please read it to learn how to build a gettext translation directory (locale).
Definition at line 79 of file GetText.php.
|
This method returns current gettext support class.
Definition at line 88 of file GetText.php. References _support(). Referenced by _support(), addDomain(), gettext(), init(), reset(), setLanguage(), setVar(), and setVars(). |
|
Add a translation domain. The domain name is usually the name of the .po file you wish to use. For example, if you created a file 'locale/ll_CC/LC_MESSAGES/myapp.po', you'll use 'myapp' as the domain name.
Definition at line 159 of file GetText.php. References _support(), addDomain(), and path. Referenced by addDomain(). |
|
Retrieve the translation for specified key.
Definition at line 171 of file GetText.php. References _support(), and gettext(). |
|
Initialize gettext package. This method instantiate the gettext support depending on managerType value. GETTEXT_NATIVE try to use gettext php support and fail back to PHP support if not installed. GETTEXT_PHP explicitely request the usage of PHP support.
Definition at line 119 of file GetText.php. References _support(), gettext(), GETTEXT_NATIVE, and init(). Referenced by init(). |
|
Reset interpolation variables. Definition at line 207 of file GetText.php. References _support(). |
|
Set the language to use for traduction.
Definition at line 139 of file GetText.php. References _support(), and setLanguage(). Referenced by setLanguage(). |
|
Add a variable to gettext interpolation system.
Definition at line 186 of file GetText.php. References _support(), and setVar(). Referenced by setVar(). |
|
Add an hashtable of variables.
Definition at line 198 of file GetText.php. References _support(), and setVars(). Referenced by setVars(). |