X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fgettext.php;h=c4b8cd15fe27bc29bfc92a073bf7f453eb6ab97c;hb=517f50995c634e600e73cf4208e90c464fe798b6;hp=4295a68bcd48aca48ebc252118bbddfd40dd8b9e;hpb=3b84e1b10d0800d858a68283bce298d15677ce58;p=squirrelmail.git diff --git a/functions/gettext.php b/functions/gettext.php index 4295a68b..c4b8cd15 100644 --- a/functions/gettext.php +++ b/functions/gettext.php @@ -1,13 +1,17 @@ error==1) return $str; + if (! isset($l10n[$gettext_domain]) || + ! is_object($l10n[$gettext_domain]) || + $l10n[$gettext_domain]->error==1) + return $str; return $l10n[$gettext_domain]->translate($str); } @@ -42,6 +50,7 @@ function _($str) { * @param string $domain gettext domain name * @param string $dir directory that contains all translations * @return string path to translation directory + * @since 1.1.2 */ function bindtextdomain($domain, $dir) { global $l10n, $sm_notAlias; @@ -57,15 +66,41 @@ function bindtextdomain($domain, $dir) { /** * Alternative php textdomain function * - * Sets default domain name + * Sets default domain name. Before 1.5.1 command required + * bindtextdomain() call for each gettext domain change. * * @link http://www.php.net/function.textdomain * @param string $name gettext domain name * @return string gettext domain name + * @since 1.1.2 */ function textdomain($name = false) { global $gettext_domain; if ($name) $gettext_domain=$name; return $gettext_domain; } + +/** + * Safety check. + * Setup where three standard gettext functions don't exist and dgettext() exists. + */ +if (! function_exists('dgettext')) { + /** + * Alternative php dgettext function + * + * @link http://www.php.net/function.dgettext + * @param string $domain Gettext domain + * @param string $str English string + * @return string translated string + * @since 1.5.1 + */ + function dgettext($domain, $str) { + global $l10n; + if (! isset($l10n[$domain]) || + ! is_object($l10n[$domain]) || + $l10n[$domain]->error==1) + return $str; + return $l10n[$domain]->translate($str); + } +} ?> \ No newline at end of file