Nette extension for bckp/translator-core

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


Downloads this Month Build Status Coverage Status Latest Stable Version License

Simple and fast PHP translator


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

$ composer require bckp/translator-nette


In you nette config, add extension with temporary dir

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

and set translator itself

		- cs #Language codes
		- %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


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

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