system('locale -a'); // get the contents from the internal output buffer $all_locales = ob_get_contents(); // fflush and end the output buffering to internal output buffer ob_end_clean(); $system_locales = explode("\n", $all_locales); // return all the locale found in the system return $system_locales; } /* Collect existing system locales and get 2 valid locales that can be use to pass as argument to setlocale(), pass 2 invalid arguments along with two valid arguments*/ echo "*** Testing setlocale() by passing multiple valid/invalid locales as argument ***\n"; //set of currency symbol according to above list of locales $currency_symbol = array("en_US.utf8" => "USD", "en_AU.utf8" => "AUD", "ko_KR.utf8" => "KRW", "zh_CN.utf8" => "CNY", "de_DE.utf8" => "EUR", "es_EC.utf8" => "USD", "fr_FR.utf8" => "EUR", "ja_JP.utf8" => "JPY", "el_GR.utf8" => "EUR", "nl_NL.utf8" => "EUR"); // gather all the locales installed in the system $all_system_locales = list_system_locales(); // Now check for three locales that is present in the system and use that as argument to setlocale() if (in_array("en_US.utf8", $all_system_locales) || in_array("Ko_KR.utf8", $all_system_locales) || in_array("zh_CN.utf8", $all_system_locales)) { echo "-- Testing setlocale() by giving 'category' as LC_ALL & multiple locales(en_US.invalid, en_US.utf8, Ko_KR.utf8, KO_KR.invalid, zh_CN.utf8) --\n"; // call setlocale() $new_locale = setlocale(LC_ALL, "en_US.invalid", "en_US.utf8", "Ko_KR.utf8", "KO_KR.invalid", "zh_CN.utf8"); // dump the name of the new locale set by setlocale() var_dump($new_locale); // check that new locale setting is effective // use localeconv() to get the details of currently set locale $locale_info = localeconv(); $new_currency = trim($locale_info['int_curr_symbol']); echo "Checking currency settings in the new locale, expected: " . $currency_symbol[$new_locale] . ", Found: " . $new_currency . "\n"; echo "Test "; if (trim($currency_symbol[$new_locale]) == $new_currency) { echo "PASSED.\n";
* * This file is part of Mandriva Management Console (MMC). * * MMC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MMC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MMC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require "config.inc.php"; require "acl.inc.php"; require "session.inc.php"; require "PageGenerator.php"; if ($_GET['value']) { $_SESSION['lang'] = $_GET['value']; header("Location: " . $_SERVER[HTTP_REFERER]); exit; } else { echo "<h3>Choix de la langue</h3>"; foreach (list_system_locales(realpath("../modules/base/locale/")) as $lang) { echo "<a href=\"includes/lang_change.php?value={$lang}\">{$lang}</a><br/>"; } }
if (strstr($key, "server_")) { $servDescList[] = $conf[$key]["description"]; $servLabelList[] = $key; } } $servList = new SelectItem("server", "changeServerLang"); $servList->setElements($servDescList); $servList->setElementsVal($servLabelList); if (isset($_GET['server'])) { $servList->setSelected($_GET['server']); } else { $servList->setSelected($servLabelList[0]); } $langLabelList = array(); $langDescList = array(); $languages = list_system_locales(realpath("modules/base/locale/")); $langDesc = getArrLocale(); foreach ($languages as $value) { if ($langDesc[$value]) { $langDescList[] = $langDesc[$value]; } else { $langDescList[] = $value; } $langLabelList[] = $value; } $langList = new SelectItem("lang", "changeServerLang"); $langList->setElements($langDescList); $langList->setElementsVal($langLabelList); if (!isset($_GET['lang'])) { // Get browser lang $lang_1 = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
<html> <body> <h1> info... </h1> <?php function list_system_locales() { ob_start(); system('locale -a'); $str = ob_get_contents(); ob_end_clean(); return trim($str); } ?> <pre><?php echo list_system_locales(); ?> </pre> <hr /> <?php phpinfo(); ?> </body> </html>