/** * Returns an instance of Collator class (ICU) created for a specified language. This collator treats substrings of digits as numbers. * @param string $language (optional) Language indentificator. If it is omited, the current interface language is assumed. * @return object Returns a instance of Collator class that is suitable for alpha-numerical comparisons. */ function _api_get_alpha_numerical_collator($language = null) { static $collator = array(); if (empty($language)) { $language = api_get_interface_language(); } if (!isset($collator[$language])) { $locale = _api_get_locale_from_language($language); $collator[$language] = collator_create($locale); if (is_object($collator[$language])) { collator_set_attribute($collator[$language], Collator::CASE_FIRST, Collator::UPPER_FIRST); collator_set_attribute($collator[$language], Collator::NUMERIC_COLLATION, Collator::ON); } } return $collator[$language]; }
function ut_coll_set_attribute($coll, $attr, $val) { return $GLOBALS['oo-mode'] ? $coll->setAttribute($attr, $val) : collator_set_attribute($coll, $attr, $val); }