Commit ca0c4a6c authored by Jakub Konečný's avatar Jakub Konečný

removed property BookControl::$lang

parent 234a6607
......@@ -3,6 +3,7 @@ Version 2.0.0-dev
- marked BookPagesStorage as final
- BC break: changed parameters of method BookPagesStorage::getIndex
- allowed Nette 3
- BC break: removed property BookControl::$lang
Version 1.4.0
- allowed customization of index and page templates
......
......@@ -96,23 +96,8 @@ $control->onRender[] = function(Book\BookControl $book, string $page) {
Translations
------------
The (few) texts used by the component are in english but you can have them translated into another language if you prefer. If translation to your language of choice is shipped, you just need to set property $lang to abbreviation of the language, preferably in constructor. Example:
```php
<?php
declare(strict_types=1);
use Nexendrie\BookComponent as Book;
class HelpControl extends Book\BookControl {
function __construct() {
$this->lang = "cs";
parent::__construct(":Front:Help", __DIR__ . "/help");
}
}
?>
```
If that translation (or some text of it) is not available, english variant is used.
The (few) texts used by the component are in english but you can have them translated into another language if you prefer. If that translation (or some text of it) is not available, english variant is used.
If you wish, you can also use your own translator. Just set property $translator in constructor. List of all texts used by the component can be seen in *src/lang/book.en.neon*.
......
......@@ -12,7 +12,6 @@ use Nexendrie\Translation\Loaders\MessagesCatalogue;
*
* @author Jakub Konečný
* @property ITranslator $translator
* @property string $lang
* @property callable|BookPagesStorage $pages
* @property string $indexTemplate
* @property string $pageTemplate
......@@ -26,8 +25,6 @@ class BookControl extends \Nette\Application\UI\Control {
private $folder;
/** @var ITranslator|Translator|null */
protected $translator;
/** @var string */
protected $lang = "";
/** @var callable|BookPagesStorage */
protected $pages;
/** @var string */
......@@ -52,14 +49,6 @@ class BookControl extends \Nette\Application\UI\Control {
$this->translator = $translator;
}
public function getLang(): string {
return $this->lang;
}
public function setLang(string $lang): void {
$this->lang = $lang;
}
/**
* @throws \InvalidArgumentException
*/
......@@ -113,9 +102,6 @@ class BookControl extends \Nette\Application\UI\Control {
$loader->folders = [__DIR__ . "/lang"];
$this->translator = new Translator($loader);
}
if($this->lang !== "") {
$this->translator->lang = $this->lang;
}
$this->template->setTranslator($this->translator);
}
......
......@@ -42,11 +42,6 @@ final class BookControlTest extends \Tester\TestCase {
$this->control->render();
}
public function testLang() {
$this->control->lang = "cs";
Assert::same("cs", $this->control->lang);
}
public function testTranslator() {
$loader = new MessagesCatalogue();
$loader->folders = [__DIR__ . "/../../../src/lang"];
......@@ -88,7 +83,6 @@ final class BookControlTest extends \Tester\TestCase {
public function testRenderI() {
Assert::type("null", $this->control->translator);
$this->control->lang = "en";
$filename = __DIR__ . "/bookIndexExpected.latte";
$this->checkRenderOutput($this->control, $filename);
Assert::type(Translator::class, $this->control->translator);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment