Skip to content

Commit

Permalink
added translator to template
Browse files Browse the repository at this point in the history
  • Loading branch information
accgit committed Feb 4, 2020
1 parent 0edca7d commit f7931e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"require": {
"php": ">=7.1",
"nette/di": "^3.0",
"nette/utils": "^3.0"
"nette/utils": "^3.0",
"nette/application": "^3.0"
},
"require-dev": {
"nette/tester": "^2.3",
Expand Down
10 changes: 8 additions & 2 deletions src/Drago/Localization/TranslatorAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Drago\Localization;

use Nette\Application\UI\Presenter;


/**
* Simple translator.
Expand All @@ -22,12 +24,16 @@ trait TranslatorAdapter
public $lang;

/** @var Translator */
public $translator;
private $translator;


public function injectTranslator(Translator $translator): void
public function injectTranslator(Translator $translator, Presenter $presenter): void
{
$this->translator = $translator;
$presenter->onRender[] = function () use ($presenter) {
$presenter->template->lang = $this->lang;
$presenter->template->setTranslator($this->getTranslator());
};
}


Expand Down

0 comments on commit f7931e8

Please sign in to comment.