bckp/translator-nette

Nette extension for bckp/translator-core

v1.0 2019-06-03 08:14 UTC

README

Downloads this Month Build Status Coverage Status Latest Stable Version License

Simple and fast PHP translator

Usage

The best way to install bckp/translator-nette is using Composer:

$ composer require bckp/translator-nette

Configuration

In you nette config, add extension with temporary dir

extensions:
	translator: Bckp\Translator\Nette\Bridges\TranslatorExtension(%tempDir%/translator)

and set translator itself

translator:
	languages:
		- cs #Language codes
	path:
		- %appDir%/Locale # Where to search for language file
	resolver: true # Use resolver to get proper language?
	debugger: %debugMode%

Translator will find all files in path and make map to the DI. If debugger is on, it will on each request check, if any file is modified and rebuild all language file (only needed ones).

Naming convention

All language files should be in Neon format, and proper naming is: ..neon

Translatings

Translator will auto-register into all presnters, that uses TranslatorAwareTrait, during onStartup part. If you want to use them in templates, you must push them into latte by yourself (as onRender is not yet implemented in nette), and onStartup is bad place to create template

<?php
class Presenter extends Nette\Application\UI\Presenter {
	use TranslatorAwarePresenter; // this comes with translator extension
}