Allows configuration of where the language files live. So that

language packs can optionally decide for themselves if they want
to use a different directory.
This commit is contained in:
Daniël Klabbers 2019-07-31 17:10:13 +02:00
parent 720c88e73a
commit 9209a5f588

View File

@ -20,6 +20,18 @@ use RuntimeException;
class LanguagePack implements ExtenderInterface, LifecycleInterface
{
protected $path;
/**
* LanguagePack constructor.
*
* @param string|null $path Path to yaml language files.
*/
public function __construct(string $path = null)
{
$this->path = $path;
}
public function extend(Container $container, Extension $extension = null)
{
if (is_null($extension)) {
@ -49,7 +61,7 @@ class LanguagePack implements ExtenderInterface, LifecycleInterface
{
$locales->addLocale($locale, $title);
$directory = $extension->getPath().'/locale';
$directory = $extension->getPath().($this->path ?? '/locale');
if (! is_dir($directory)) {
throw new RuntimeException(