Skip to content

Commit

Permalink
[Locale] add getIcuVersion and getIcuDataVersion to Locale
Browse files Browse the repository at this point in the history
  • Loading branch information
stealth35 committed Nov 9, 2011
1 parent 679bf53 commit 796c6b2
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/Symfony/Component/Locale/Locale.php
Expand Up @@ -164,4 +164,54 @@ static public function getLocales()
{
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]);
}
}

0 comments on commit 796c6b2

Please sign in to comment.