39 lines
974 B
PHP
39 lines
974 B
PHP
|
<?php
|
||
|
|
||
|
namespace Symfony\Component\Translation\Loader;
|
||
|
|
||
|
use Symfony\Component\Translation\MessageCatalogue;
|
||
|
use Symfony\Component\Translation\Resource\FileResource;
|
||
|
use Symfony\Component\Yaml\Yaml;
|
||
|
|
||
|
/*
|
||
|
* This file is part of the Symfony framework.
|
||
|
*
|
||
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
||
|
*
|
||
|
* This source file is subject to the MIT license that is bundled
|
||
|
* with this source code in the file LICENSE.
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* YamlFileLoader loads translations from Yaml files.
|
||
|
*
|
||
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||
|
*/
|
||
|
class YamlFileLoader implements LoaderInterface
|
||
|
{
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function load($resource, $locale, $domain = 'messages')
|
||
|
{
|
||
|
$messages = Yaml::load($resource);
|
||
|
|
||
|
$catalogue = new MessageCatalogue($locale);
|
||
|
$catalogue->addMessages($messages, $domain);
|
||
|
$catalogue->addResource(new FileResource($resource));
|
||
|
|
||
|
return $catalogue;
|
||
|
}
|
||
|
}
|