public function MoFileLoader::load in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/translation/Loader/MoFileLoader.php \Symfony\Component\Translation\Loader\MoFileLoader::load()
Loads a locale.
Parameters
mixed $resource A resource:
string $locale A locale:
string $domain The domain:
Return value
MessageCatalogue A MessageCatalogue instance
Throws
NotFoundResourceException when the resource cannot be found
InvalidResourceException when the resource cannot be loaded
Overrides ArrayLoader::load
File
- vendor/
symfony/ translation/ Loader/ MoFileLoader.php, line 46
Class
- MoFileLoader
- @copyright Copyright (c) 2010, Union of RAD http://union-of-rad.org (http://lithify.me/)
Namespace
Symfony\Component\Translation\LoaderCode
public function load($resource, $locale, $domain = 'messages') {
if (!stream_is_local($resource)) {
throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
}
if (!file_exists($resource)) {
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
}
$messages = $this
->parse($resource);
// empty file
if (null === $messages) {
$messages = array();
}
// not an array
if (!is_array($messages)) {
throw new InvalidResourceException(sprintf('The file "%s" must contain a valid mo file.', $resource));
}
$catalogue = parent::load($messages, $locale, $domain);
if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
$catalogue
->addResource(new FileResource($resource));
}
return $catalogue;
}