merged branch stealth35/patch-14 (PR #2581)

Commits
-------

796c6b2 [Locale] add getIcuVersion and getIcuDataVersion to Locale

Discussion
----------

[Locale] add getIcuVersion and getIcuDataVersion to Locale

---------------------------------------------------------------------------

by stealth35 at 2011/11/09 00:51:30 -0800

@stof thank for your review
This commit is contained in:
Fabien Potencier 2011-11-09 21:53:59 +01:00
commit df88070e76

View File

@ -164,4 +164,54 @@ class Locale extends \Locale
{
return array_keys(self::getDisplayLocales(self::getDefault()));
}
/**
* Returns the ICU version
*
* @return string|null The ICU version
*/
static public function getIcuVersion()
{
if (defined('INTL_ICU_VERSION')) {
return INTL_ICU_VERSION;
}
try {
$reflector = new \ReflectionExtension('intl');
} catch(\ReflectionException $e) {
return;
}
ob_start();
$reflector->info();
$output = strip_tags(ob_get_clean());
preg_match('/^ICU version (?:=>)?(.*)$/m', $output, $matches);
return trim($matches[1]);
}
/**
* Returns the ICU Data version
*
* @return string|null The ICU Data version
*/
static public function getIcuDataVersion()
{
if (defined('INTL_ICU_DATA_VERSION')) {
return INTL_ICU_DATA_VERSION;
}
try {
$reflector = new \ReflectionExtension('intl');
} catch(\ReflectionException $e) {
return;
}
ob_start();
$reflector->info();
$output = strip_tags(ob_get_clean());
preg_match('/^ICU Data version (?:=>)?(.*)$/m', $output, $matches);
return trim($matches[1]);
}
}