GNU Gettext
gettext
The gettext functions implement a NLS (Native Language Support)
API which can be used to internationalize your PHP applications.
Please see the GNU gettext documentation for a thorough explanation
of these functions.
bindtextdomain
Sets the path for a domain
Description
string bindtextdomain
string domain
string directory
The bindtextdomain function sets the path
for a domain.
dcgettext
Overrides the domain for a single lookup
Description
string dcgettext
string domain
string message
int category
This function allows you to override the current domain for a
single message lookup. It also allows you to specify a category.
dgettext
Override the current domain
Description
string dgettext
string domain
string message
The dgettext function allows you to override
the current domain for a single message lookup.
gettext
Lookup a message in the current domain
Description
string gettext
string message
This function returns a translated string if one is found in the
translation table, or the submitted message if not found. You may
use an underscore character as an alias to this function.
Gettext-check
<?php
// Set language to German
putenv ("LANG=de");
// Specify location of translation tables
bindtextdomain ("myPHPApp", "./locale");
// Choose domain
textdomain ("myPHPApp");
// Print a test message
print (gettext ("Welcome to My PHP Application"));
?>
textdomain
Sets the default domain
Description
string textdomain
string text_domain
This function sets the domain to search within when calls are
made to gettext, usually the named after an
application. The previous default domain is returned. Call it
with no parameters to get the current setting without changing
it.