/** * Wrapper function for setLocale() so that all the proper permutations are used * Returns the result from the setLocale call * @param $locale the local desired * @return string */ function i18nSetLocale($locale) { global $_zp_RTL_css; $en1 = LOCAL_CHARSET; $en2 = str_replace('ISO-', 'ISO', $en1); $simple = explode('-', $locale); $rslt = setlocale(LC_ALL, $locale . '.UTF8', $locale . '.UTF-8', $locale . '@euro', $locale . '.' . $en2, $locale . '.' . $en1, $locale, $simple[0], NULL); setupLanguageArray(); $_zp_RTL_css = in_array(substr($rslt, 0, 2), array('fa', 'ar', 'he', 'hi', 'ur')); return $rslt; }
/** * Returns the sring for the current language from a serialized set of language strings * Defaults to the string for the current locale, the en_US string, or the first string which ever is present * * @param string $dbstring either a serialized languag string array or a single string * @param string $locale optional locale of the translation desired * @return string */ function get_language_string($dbstring, $locale = NULL) { if (!preg_match('/^a:[0-9]+:{/', $dbstring)) { return $dbstring; } $strings = unserialize($dbstring); $actual_local = getOption('locale'); if (is_null($locale)) { $locale = $actual_local; } if (isset($strings[$locale])) { return $strings[$locale]; } if (isset($strings[$actual_local])) { return $strings[$actual_local]; } if (isset($strings['en_US'])) { return $strings['en_US']; } return array_shift($strings); } setupLanguageArray();