Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/TranslationDriver/SymfonyTranslationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Symfony\Component\Translation\Loader\MoFileLoader;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Translation\TranslatorInterface;

class SymfonyTranslationDriver implements TranslationDriverInterface
{
Expand All @@ -19,9 +20,12 @@ class SymfonyTranslationDriver implements TranslationDriverInterface
*/
private $locale = 'en';

public function __construct(?string $cacheDirectory = null)
/**
* @param string|null $cacheDirectory useful only if the given $translator is null.
*/
public function __construct(?string $cacheDirectory = null, ?TranslatorInterface $translator = null)
{
$this->translator = new Translator($this->locale, null, $cacheDirectory);
$this->translator = $translator ?: new Translator($this->locale, null, $cacheDirectory);
$this->translator->addLoader('mo', new MoFileLoader());
}

Expand Down