PHPackages                             bckp/translator-nette - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. bckp/translator-nette

ActiveLibrary[Localization &amp; i18n](/categories/localization)

bckp/translator-nette
=====================

Nette extension for bckp/translator-core

v1.0(6y ago)14.0kBSD-3-ClausePHPPHP &gt;=7.1.0CI passing

Since Jun 3Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/bckp/translator-nette)[ Packagist](https://packagist.org/packages/bckp/translator-nette)[ Docs](https://github.com/bckp/translator-nette)[ RSS](/packages/bckp-translator-nette/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

Bckp\\Translator
================

[](#bckptranslator)

[![Downloads this Month](https://camo.githubusercontent.com/a198979bb5def7c4c9fe50929d96bdf956c1fb5ed02d399cc48b115678421c06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f62636b702f7472616e736c61746f722d6e657474652e737667)](https://packagist.org/packages/bckp/translator-nette)[![Tests](https://github.com/bckp/translator-nette/actions/workflows/tests.yaml/badge.svg)](https://github.com/bckp/translator-nette/actions/workflows/tests.yaml)[![Coverage Status](https://camo.githubusercontent.com/1f02527c72ab83fa2d8eeef4b3beb3063e67fe94b45362fe14726d2b52ddedaa/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62636b702f7472616e736c61746f722d6e657474652f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/bckp/translator-nette?branch=main)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/07455a2ccb1a86563f3219c126efa5e904b8df4c15608759de7408a92f793afb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62636b702f7472616e736c61746f722d6e657474652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/bckp/translator-nette/?branch=main)[![Latest Stable Version](https://camo.githubusercontent.com/2b894475666000fd8fe52e5fc1838fcf613514dbfa418ade7c1a8c769d4bb319/68747470733a2f2f706f7365722e707567782e6f72672f62636b702f7472616e736c61746f722d6e657474652f762f737461626c65)](https://packagist.org/packages/bckp/translator-nette)[![License](https://camo.githubusercontent.com/fa7d5fcf2c84b580327af52da95dd751703af65f079dc3c5a0081beac0789718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667)](https://github.com/nette/application/blob/master/license.md)

Simple and fast PHP translator

Usage
-----

[](#usage)

The best way to install bckp/translator-nette is using [Composer](http://getcomposer.org/):

```
$ composer require bckp/translator-nette
```

Configuration
-------------

[](#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
	pluralProvider: Bckp\Translator\PluralProvider # Optional - default is PluralProvider from bckp/translator-core
	debugger: %debugMode% # Optional - default is %debugMode%
	injectLatte: true # Optional - default is true, this will autoregister translator into latte
	resolvers:
	    - Bckp\Translator\Nette\Resolvers\HeaderLocaleResolver() # Any class implements Resolver, will be used to resolve language, if more then one used, extension will cyclu thru all of them to find first that can be used
```

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
-----------------

[](#naming-convention)

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

Translation file format
-----------------------

[](#translation-file-format)

Translation files are written in NEON format. Plural strings are in ARRAY, otherwise STRING.

```
welcome: 'Vítejte'
withArgs: 'Ahoj, já jsem %s, přeji krásné %s'
withArgsRev: 'Krásné %2$s, já jsem %1$s'
plural:
	zero: 'žádný člověk'
	one: 'jeden člověk'
	few: '%d lidé'
	other: '%d lidí'
next: 'This is next translation'
```

Translatings
------------

[](#translatings)

For translator to be in Presenter, simply inject it or get in in constructor

```
