There are two example coming with "php-gettext" package. However, it is realy easy since you have to use only:
print T_gettext("Hello World");
or
print sprintf(T_ngettext("%i Developer",
"%i Developers", ${COUNT}), $COUNT);
Run the command
xgettext -k T_gettext -k T_ -L PHP -o script.pot script.php
and then you have the Translation Template.
Copy it to your desired language like
cp script.pot script.po
and translate the "msgstr". Not call the command
msgfmt -o script.mo script.po
and copy the file script.mo to your desired locale directory with e.g.
cp script.mo /var/www/locale/de/LC_messages/
and then setup your script.php to use
----[ 'script.php' ]----------------------------------------------------
<?php
define(PROJECT_DIR, realpath('/var/www'));
define(LOCALE_DIR, PROJECT_DIR .'/locale');
define(DEFAULT_LOCALE, 'en_US');
require_once('/usr/share/php/php-gettext/gettext.inc');
$supported_locales = array('de_DE', 'de', 'en_US', 'en');
$encoding = 'UTF-8';
$locale = (isset($_GET['lang']))? $_GET['lang'] : DEFAULT_LOCALE;
T_setlocale(LC_MESSAGES, $locale);
$domain = 'script';
bindtextdomain($domain, LOCALE_DIR);
bind_textdomain_codeset($domain, $encoding);
textdomain($domain);
print T_gettext("The rest of your script");
?>
----8<------------------------------------------------------------------
Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant
--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
<http://www.tamay-dogan.net/> Michelle Konzack
<http://www.can4linux.org/> Apt. 917
<http://www.flexray4linux.org/> 50, rue de Soultz
Jabber [email protected] 67100 Strasbourg/France
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886 Tel. FR: +33 6 61925193
signature.pgp
Description: Digital signature

