chomenko / translator
Translator for Nette Framework
Installs: 654
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Type:extensions
Requires
- php: ^5.6 || ^7.0
- nette/caching: ^2.5
- nette/di: ^2.4
- nette/neon: ^3.0
- nette/utils: ^2.4
- nettpack/stage: ^1.0
README
Extension from Nette\Localization
Required:
Install
composer require chomenko/translator
In base config.neon:
translator: localDir: %appDir%/Localization defaultLang: cs #pattern: '/%+([a-z0-9]+)/u' #old pattern style %value, new style is {{ value }} extensions: translator: Chomenko\Translator\DI\TranslatorExtension
In base presenter:
<?php namespace App\Presenters; use Nette\Application\UI\Presenter; use Chomenko\Translator\Translate; class BasePresenter extends Presenter { /** * Install Translator */ use Translate; public function startup() { parent::startup(); $config = $this->translator->getConfig(); $this->template->setTranslator($this->translator); } }
In latte:
{_"name", ["Jméno"]} {*Default value. Used if value is not stored*} {_"Name is: {{ name }}", ["name" => "Franta"]} {_"Birthdate: {{ date }}", 1991}
Translate Modal
Use only in the developer mode. Do not use for production!!
The translation modal can be invoked by pressing CTRL + ALT + mouse CLICK translate item
. Translating elements turn red
Modal is required Bootstrap and JQuery. If you are developing on Unix you will need to set the right to write
In presenter:
<?php $config = $this->translator->getConfig(); $config->translateModalEnable();
In @layout.latte:
{control translateModal}