Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df88070

Browse files
committed
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
2 parents c3fc52e + 796c6b2 commit df88070

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

src/Symfony/Component/Locale/Locale.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,54 @@ static public function getLocales()
164164
{
165165
return array_keys(self::getDisplayLocales(self::getDefault()));
166166
}
167+
168+
/**
169+
* Returns the ICU version
170+
*
171+
* @return string|null The ICU version
172+
*/
173+
static public function getIcuVersion()
174+
{
175+
if (defined('INTL_ICU_VERSION')) {
176+
return INTL_ICU_VERSION;
177+
}
178+
179+
try {
180+
$reflector = new \ReflectionExtension('intl');
181+
} catch(\ReflectionException $e) {
182+
return;
183+
}
184+
185+
ob_start();
186+
$reflector->info();
187+
$output = strip_tags(ob_get_clean());
188+
preg_match('/^ICU version (?:=>)?(.*)$/m', $output, $matches);
189+
190+
return trim($matches[1]);
191+
}
192+
193+
/**
194+
* Returns the ICU Data version
195+
*
196+
* @return string|null The ICU Data version
197+
*/
198+
static public function getIcuDataVersion()
199+
{
200+
if (defined('INTL_ICU_DATA_VERSION')) {
201+
return INTL_ICU_DATA_VERSION;
202+
}
203+
204+
try {
205+
$reflector = new \ReflectionExtension('intl');
206+
} catch(\ReflectionException $e) {
207+
return;
208+
}
209+
210+
ob_start();
211+
$reflector->info();
212+
$output = strip_tags(ob_get_clean());
213+
preg_match('/^ICU Data version (?:=>)?(.*)$/m', $output, $matches);
214+
215+
return trim($matches[1]);
216+
}
167217
}

0 commit comments

Comments
 (0)