/** * Sets a requested locale, if needed emulates it. */ function _setlocale($category, $locale) { if ($locale === 0) { // use === to differentiate between string "0" if (domain::$CURRENTLOCALE != '') { return domain::$CURRENTLOCALE; } else { // obey LANG variable, maybe extend to support all of LC_* vars // even if we tried to read locale without setting it first return _setlocale($category, domain::$CURRENTLOCALE); } } else { if (function_exists('setlocale')) { $ret = setlocale($category, $locale); if ($locale == '' and !$ret or $locale != '' and $ret != $locale) { // failed setting it // Failed setting it according to environment. domain::$CURRENTLOCALE = _get_default_locale($locale); domain::$EMULATEGETTEXT = 1; } else { domain::$CURRENTLOCALE = $ret; domain::$EMULATEGETTEXT = 0; } } else { // No function setlocale(), emulate it all. domain::$CURRENTLOCALE = _get_default_locale($locale); domain::$EMULATEGETTEXT = 1; } // Allow locale to be changed on the go for one translation domain. if (isset(domain::$text_domains[domain::$default_domain])) { unset(domain::$text_domains[domain::$default_domain]->l10n); } return domain::$CURRENTLOCALE; } }