Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 1.73 KB

README.md

File metadata and controls

82 lines (62 loc) · 1.73 KB

Translator

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

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}