[Translation] Make IcuDatFileLoader/IcuResFileLoader::load invalid resource compatible with HHVM.
This commit is contained in:
parent
73f6c16163
commit
9bc08c0279
@ -28,7 +28,12 @@ class BinaryBundleReader extends AbstractBundleReader implements BundleReaderInt
|
||||
{
|
||||
// Point for future extension: Modify this class so that it works also
|
||||
// if the \ResourceBundle class is not available.
|
||||
$bundle = new \ResourceBundle($locale, $path);
|
||||
try {
|
||||
$bundle = new \ResourceBundle($locale, $path);
|
||||
} catch (\Exception $e) {
|
||||
// HHVM compatibility: constructor throws on invalid resource
|
||||
$bundle = null;
|
||||
}
|
||||
|
||||
if (null === $bundle) {
|
||||
throw new RuntimeException(sprintf(
|
||||
|
@ -119,7 +119,12 @@ class LocaleBundleTransformationRule implements TransformationRuleInterface
|
||||
}
|
||||
|
||||
// Delete locales that have no content (i.e. only "Version" key)
|
||||
$bundle = new \ResourceBundle($locale, $tempDir);
|
||||
try {
|
||||
$bundle = new \ResourceBundle($locale, $tempDir);
|
||||
} catch (\Exception $e) {
|
||||
// HHVM compatibility: constructor throws on invalid resource
|
||||
$bundle = null;
|
||||
}
|
||||
|
||||
if (null === $bundle) {
|
||||
throw new RuntimeException('The resource bundle for locale ' . $locale . ' could not be loaded from directory ' . $tempDir);
|
||||
|
@ -36,7 +36,12 @@ class IcuDatFileLoader extends IcuResFileLoader
|
||||
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
|
||||
}
|
||||
|
||||
$rb = new \ResourceBundle($locale, $resource);
|
||||
try {
|
||||
$rb = new \ResourceBundle($locale, $resource);
|
||||
} catch (\Exception $e) {
|
||||
// HHVM compatibility: constructor throws on invalid resource
|
||||
$rb = null;
|
||||
}
|
||||
|
||||
if (!$rb) {
|
||||
throw new InvalidResourceException(sprintf('Cannot load resource "%s"', $resource));
|
||||
|
@ -36,7 +36,12 @@ class IcuResFileLoader implements LoaderInterface
|
||||
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
|
||||
}
|
||||
|
||||
$rb = new \ResourceBundle($locale, $resource);
|
||||
try {
|
||||
$rb = new \ResourceBundle($locale, $resource);
|
||||
} catch (\Exception $e) {
|
||||
// HHVM compatibility: constructor throws on invalid resource
|
||||
$rb = null;
|
||||
}
|
||||
|
||||
if (!$rb) {
|
||||
throw new InvalidResourceException(sprintf('Cannot load resource "%s"', $resource));
|
||||
|
Reference in New Issue
Block a user