X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fi18n.php;h=554ab4427c189a458c62a67b43618ae68b733f5c;hb=8090d1fd72309733aa89fd86da06c5086e27ebf3;hp=ebd0118cf527716f86f436a399750cc6f9d2bb28;hpb=5a4689fbd25ea129a960c93043b6671805a6210f;p=squirrelmail.git diff --git a/functions/i18n.php b/functions/i18n.php index ebd0118c..554ab442 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -2,7 +2,7 @@ /** * SquirrelMail internationalization functions * - * Copyright (c) 1999-2004 The SquirrelMail Project Team + * Copyright (c) 1999-2005 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This file contains variuos functions that are needed to do @@ -59,6 +59,39 @@ function sq_textdomain($domain) { return $gettext_domain; } +/** + * php setlocale function wrapper + * + * From php 4.3.0 it is possible to use arrays in order to set locale. + * php gettext extension works only when locale is set. This wrapper + * function allows to use more than one locale name. + * + * @param int $category locale category name. Use php named constants + * (LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME) + * @param mixed $locale option contains array with possible locales or string with one locale + * @return string name of set locale or false, if all locales fail. + * @since 1.5.1 and 1.4.5 + * @see http://www.php.net/setlocale + */ +function sq_setlocale($category,$locale) { + // string with only one locale + if (is_string($locale)) + return setlocale($category,$locale); + + if (! check_php_version(4,3)) { + $ret=false; + $index=0; + while ( ! $ret && $index