zahy/localization

Simply translator for Nette Framework

v0.1.1 2018-02-11 14:41 UTC

README

Simple Translator for Nette Framework

Requirements

Installation

Install with Composer:

$ composer require zahy/localization

Register extension:

extensions:
	localization: ZahyCZ\Localization\DI\Extension

Configuration:

localization:
  languages: ['cs', 'en']
  locPath: '/../localization'
  storageName: 'ZahyCZ.Localization'

Localization files example:

Example:
	cs: Příklad
	en: Example

Example file name: example.loc.neon

Using

Inject Service:

/**
* Translator
* @var Nette\Localization\ITranslator @inject
*/
public $translator;

Using in PHP:

$this->translator->setLanguage('cs');
$this->translator->translate('Example', ['text']);

Using in Latte:

{_'Example', ['text']}