3 * SquirrelMail internal gettext functions
5 * Uses php-gettext classes
6 * @copyright (c) 1999-2005 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public Licens
8 * @link http://www.php.net/gettext Original php gettext manual
9 * @link http://savannah.nongnu.org/projects/php-gettext php-gettext classes
11 * @package squirrelmail
15 /** Almost everything requires global.php... */
16 require_once(SM_PATH
. 'functions/global.php');
18 /** Load classes and other functions */
19 include_once(SM_PATH
. 'class/l10n.class.php');
20 include_once(SM_PATH
. 'functions/ngettext.php');
23 * Alternative php gettext function (short form)
25 * @link http://www.php.net/function.gettext
27 * @param string $str English string
28 * @return string translated string
31 global $l10n, $gettext_domain;
32 if ($l10n[$gettext_domain]->error
==1) return $str;
33 return $l10n[$gettext_domain]->translate($str);
37 * Alternative php bindtextdomain function
39 * Sets path to directory containing domain translations
41 * @link http://www.php.net/function.bindtextdomain
42 * @param string $domain gettext domain name
43 * @param string $dir directory that contains all translations
44 * @return string path to translation directory
46 function bindtextdomain($domain, $dir) {
47 global $l10n, $sm_notAlias;
48 if (substr($dir, -1) != '/') $dir .= '/';
49 $mofile=$dir . $sm_notAlias . '/LC_MESSAGES/' . $domain . '.mo';
51 $input = new FileReader($mofile);
52 $l10n[$domain] = new gettext_reader($input);
58 * Alternative php textdomain function
60 * Sets default domain name
62 * @link http://www.php.net/function.textdomain
63 * @param string $name gettext domain name
64 * @return string gettext domain name
66 function textdomain($name = false) {
67 global $gettext_domain;
68 if ($name) $gettext_domain=$name;
69 return $gettext_domain;