4 * SquirrelMail internal gettext functions
6 * Since 1.5.1 uses php-gettext classes.
7 * Original implementation was done by Tyler Akins (fidian)
9 * @link http://www.php.net/gettext Original php gettext manual
10 * @link http://savannah.nongnu.org/projects/php-gettext php-gettext classes
11 * @copyright © 1999-2007 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
15 * @package squirrelmail
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 (! isset($l10n[$gettext_domain]) ||
36 ! is_object($l10n[$gettext_domain]) ||
37 $l10n[$gettext_domain]->error
==1)
39 return $l10n[$gettext_domain]->translate($str);
43 * Alternative php bindtextdomain function
45 * Sets path to directory containing domain translations
47 * @link http://www.php.net/function.bindtextdomain
48 * @param string $domain gettext domain name
49 * @param string $dir directory that contains all translations
50 * @return string path to translation directory
53 function bindtextdomain($domain, $dir) {
54 global $l10n, $sm_notAlias;
55 if (substr($dir, -1) != '/') $dir .= '/';
56 $mofile=$dir . $sm_notAlias . '/LC_MESSAGES/' . $domain . '.mo';
58 $input = new FileReader($mofile);
59 $l10n[$domain] = new gettext_reader($input);
65 * Alternative php textdomain function
67 * Sets default domain name. Before 1.5.1 command required
68 * bindtextdomain() call for each gettext domain change.
70 * @link http://www.php.net/function.textdomain
71 * @param string $name gettext domain name
72 * @return string gettext domain name
75 function textdomain($name = false) {
76 global $gettext_domain;
77 if ($name) $gettext_domain=$name;
78 return $gettext_domain;
83 * Setup where three standard gettext functions don't exist and dgettext() exists.
85 if (! function_exists('dgettext')) {
87 * Alternative php dgettext function
89 * @link http://www.php.net/function.dgettext
90 * @param string $domain Gettext domain
91 * @param string $str English string
92 * @return string translated string
95 function dgettext($domain, $str) {
97 if (! isset($l10n[$domain]) ||
98 ! is_object($l10n[$domain]) ||
99 $l10n[$domain]->error
==1)
101 return $l10n[$domain]->translate($str);