3 * SquirrelMail internal gettext functions
5 * Since 1.5.1 uses php-gettext classes.
6 * Original implementation was done by Tyler Akins (fidian)
7 * @copyright (c) 1999-2005 The SquirrelMail Project Team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 * @link http://www.php.net/gettext Original php gettext manual
10 * @link http://savannah.nongnu.org/projects/php-gettext php-gettext classes
13 * @package squirrelmail
17 /** Almost everything requires global.php... */
18 require_once(SM_PATH
. 'functions/global.php');
20 /** Load classes and other functions */
21 include_once(SM_PATH
. 'class/l10n.class.php');
22 include_once(SM_PATH
. 'functions/ngettext.php');
25 * Alternative php gettext function (short form)
27 * @link http://www.php.net/function.gettext
29 * @param string $str English string
30 * @return string translated string
34 global $l10n, $gettext_domain;
35 if ($l10n[$gettext_domain]->error
==1) return $str;
36 return $l10n[$gettext_domain]->translate($str);
40 * Alternative php bindtextdomain function
42 * Sets path to directory containing domain translations
44 * @link http://www.php.net/function.bindtextdomain
45 * @param string $domain gettext domain name
46 * @param string $dir directory that contains all translations
47 * @return string path to translation directory
50 function bindtextdomain($domain, $dir) {
51 global $l10n, $sm_notAlias;
52 if (substr($dir, -1) != '/') $dir .= '/';
53 $mofile=$dir . $sm_notAlias . '/LC_MESSAGES/' . $domain . '.mo';
55 $input = new FileReader($mofile);
56 $l10n[$domain] = new gettext_reader($input);
62 * Alternative php textdomain function
64 * Sets default domain name. Before 1.5.1 command required
65 * bindtextdomain() call for each gettext domain change.
67 * @link http://www.php.net/function.textdomain
68 * @param string $name gettext domain name
69 * @return string gettext domain name
72 function textdomain($name = false) {
73 global $gettext_domain;
74 if ($name) $gettext_domain=$name;
75 return $gettext_domain;