chomenko/translator

There is no license information available for the latest version (v2.0.1) of this package.

Translator for Nette Framework

v2.0.1 2019-07-24 11:01 UTC

This package is auto-updated.

Last update: 2024-03-14 21:58:33 UTC


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

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}