[Locale] updated ICU data paths
This commit is contained in:
parent
64ccee7f98
commit
5fd4eb1c3a
@ -43,7 +43,7 @@ class Locale extends \Locale
|
|||||||
public static function getDisplayCountries($locale)
|
public static function getDisplayCountries($locale)
|
||||||
{
|
{
|
||||||
if (!isset(self::$countries[$locale])) {
|
if (!isset(self::$countries[$locale])) {
|
||||||
$bundle = \ResourceBundle::create($locale, __DIR__.'/Resources/data/region');
|
$bundle = \ResourceBundle::create($locale, self::getDataDirectory().'/region');
|
||||||
|
|
||||||
if (null === $bundle) {
|
if (null === $bundle) {
|
||||||
throw new \RuntimeException(sprintf('The country resource bundle could not be loaded for locale "%s"', $locale));
|
throw new \RuntimeException(sprintf('The country resource bundle could not be loaded for locale "%s"', $locale));
|
||||||
@ -98,7 +98,7 @@ class Locale extends \Locale
|
|||||||
public static function getDisplayLanguages($locale)
|
public static function getDisplayLanguages($locale)
|
||||||
{
|
{
|
||||||
if (!isset(self::$languages[$locale])) {
|
if (!isset(self::$languages[$locale])) {
|
||||||
$bundle = \ResourceBundle::create($locale, __DIR__.'/Resources/data/lang');
|
$bundle = \ResourceBundle::create($locale, self::getDataDirectory().'/lang');
|
||||||
|
|
||||||
if (null === $bundle) {
|
if (null === $bundle) {
|
||||||
throw new \RuntimeException(sprintf('The language resource bundle could not be loaded for locale "%s"', $locale));
|
throw new \RuntimeException(sprintf('The language resource bundle could not be loaded for locale "%s"', $locale));
|
||||||
@ -149,7 +149,7 @@ class Locale extends \Locale
|
|||||||
public static function getDisplayLocales($locale)
|
public static function getDisplayLocales($locale)
|
||||||
{
|
{
|
||||||
if (!isset(self::$locales[$locale])) {
|
if (!isset(self::$locales[$locale])) {
|
||||||
$bundle = \ResourceBundle::create($locale, __DIR__.'/Resources/data/names');
|
$bundle = \ResourceBundle::create($locale, self::getDataDirectory().'/names');
|
||||||
|
|
||||||
if (null === $bundle) {
|
if (null === $bundle) {
|
||||||
throw new \RuntimeException(sprintf('The locale resource bundle could not be loaded for locale "%s"', $locale));
|
throw new \RuntimeException(sprintf('The locale resource bundle could not be loaded for locale "%s"', $locale));
|
||||||
@ -237,6 +237,28 @@ class Locale extends \Locale
|
|||||||
return trim($matches[1]);
|
return trim($matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getDataVersion()
|
||||||
|
{
|
||||||
|
static $dataVersion;
|
||||||
|
|
||||||
|
if (null === $dataVersion) {
|
||||||
|
$dataVersion = 'current';
|
||||||
|
|
||||||
|
if (getenv('ICU_DATA_VERSION')) {
|
||||||
|
$dataVersion = getenv('ICU_DATA_VERSION');
|
||||||
|
} elseif (file_exists(__DIR__.'/../Resources/data/data-version.php')) {
|
||||||
|
$dataVersion = include __DIR__.'/../Resources/data/data-version.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dataVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDataDirectory()
|
||||||
|
{
|
||||||
|
return __DIR__.'/Resources/data/'.self::getDataVersion();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fallback locale for a given locale, if any
|
* Returns the fallback locale for a given locale, if any
|
||||||
*
|
*
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Locale\Stub;
|
namespace Symfony\Component\Locale\Stub;
|
||||||
|
|
||||||
|
use Symfony\Component\Locale\Locale;
|
||||||
use Symfony\Component\Locale\Exception\NotImplementedException;
|
use Symfony\Component\Locale\Exception\NotImplementedException;
|
||||||
use Symfony\Component\Locale\Exception\MethodNotImplementedException;
|
use Symfony\Component\Locale\Exception\MethodNotImplementedException;
|
||||||
|
|
||||||
@ -480,12 +481,14 @@ class StubLocale
|
|||||||
*/
|
*/
|
||||||
private static function getStubData($locale, $cacheVariable, $stubDataDir)
|
private static function getStubData($locale, $cacheVariable, $stubDataDir)
|
||||||
{
|
{
|
||||||
|
$dataDirectory = Locale::getDataDirectory();
|
||||||
|
|
||||||
if ('en' !== $locale) {
|
if ('en' !== $locale) {
|
||||||
throw new \InvalidArgumentException(sprintf('Only the \'en\' locale is supported. %s', NotImplementedException::INTL_INSTALL_MESSAGE));
|
throw new \InvalidArgumentException(sprintf('Only the \'en\' locale is supported. %s', NotImplementedException::INTL_INSTALL_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(self::${$cacheVariable})) {
|
if (empty(self::${$cacheVariable})) {
|
||||||
self::${$cacheVariable} = include __DIR__.'/../Resources/data/stub/'.$stubDataDir.'/en.php';
|
self::${$cacheVariable} = include __DIR__.'/../Resources/data/'.$dataDirectory.'/stub/'.$stubDataDir.'/en.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::${$cacheVariable};
|
return self::${$cacheVariable};
|
||||||
|
Reference in New Issue
Block a user