You are here

public function IniFileLoader::load in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/translation/Loader/IniFileLoader.php \Symfony\Component\Translation\Loader\IniFileLoader::load()
  2. 8.0 vendor/symfony/dependency-injection/Loader/IniFileLoader.php \Symfony\Component\DependencyInjection\Loader\IniFileLoader::load()
Same name and namespace in other branches
  1. 8 vendor/symfony/translation/Loader/IniFileLoader.php \Symfony\Component\Translation\Loader\IniFileLoader::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/IniFileLoader.php, line 28

Class

IniFileLoader
IniFileLoader loads translations from an ini file.

Namespace

Symfony\Component\Translation\Loader

Code

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 = parse_ini_file($resource, true);
  $catalogue = parent::load($messages, $locale, $domain);
  if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
    $catalogue
      ->addResource(new FileResource($resource));
  }
  return $catalogue;
}