PHPackages                             drago-ex/translator - 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. drago-ex/translator

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

drago-ex/translator
===================

Lightweight translator for Nette Framework using NEON files, supporting global and module-specific translations.

v2.0.0(4mo ago)22.7k4MITPHPPHP &gt;=8.3 &lt;9CI passing

Since Oct 9Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/drago-ex/translator)[ Packagist](https://packagist.org/packages/drago-ex/translator)[ RSS](/packages/drago-ex-translator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (14)Used By (4)

Drago Translator
----------------

[](#drago-translator)

Lightweight translator for Nette Framework using NEON files, supporting global and module-specific translations.

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://raw.githubusercontent.com/drago-ex/translator/master/license)[![PHP version](https://camo.githubusercontent.com/2a8170606af2c9b364f35b5a728c804a62b5f510710760cc0cc6cc3387253cc7/68747470733a2f2f62616467652e667572792e696f2f70682f647261676f2d65782532467472616e736c61746f722e737667)](https://badge.fury.io/ph/drago-ex%2Ftranslator)[![Tests](https://github.com/drago-ex/translator/actions/workflows/tests.yml/badge.svg)](https://github.com/drago-ex/translator/actions/workflows/tests.yml)[![Coding Style](https://github.com/drago-ex/translator/actions/workflows/coding-style.yml/badge.svg)](https://github.com/drago-ex/translator/actions/workflows/coding-style.yml)[![CodeFactor](https://camo.githubusercontent.com/5e9f48ccfb5c2184a6fc3a3c6a0864c64c7aeeeb6baa725f96611cfb1fa05813/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f647261676f2d65782f7472616e736c61746f722f6261646765)](https://www.codefactor.io/repository/github/drago-ex/translator)[![Coverage Status](https://camo.githubusercontent.com/c10a4cbf6a556ce8fbcc059cad8714c35a05a4244cb680f210562b896c59f9c4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f647261676f2d65782f7472616e736c61746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/drago-ex/translator?branch=master)

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3
- Nette Framework
- Composer

Installation
------------

[](#installation)

```
composer require drago-ex/translator

```

Extension registration
----------------------

[](#extension-registration)

Register the DI extension in your NEON configuration.

```
extensions:
	translator: Drago\Localization\DI\TranslatorExtension(%appDir%, %tempDir%)
```

Optional configuration
----------------------

[](#optional-configuration)

```
translator:
	autoFinder: false
	translateDirs:
		- %appDir%/First/Translate
		- %appDir%/Second/Translate
```

Translator Behavior
-------------------

[](#translator-behavior)

- All directories listed in translateDirs are loaded in order.
- Later directories override translations from earlier ones.
- If autoFinder is enabled, the entire application directory is scanned for NEON files.

Translation files must be named by language code:

```
cs.neon
en.neon

```

Translation File Format
-----------------------

[](#translation-file-format)

```
"Hello, world!": "Hello, world!"
```

Using Translator in Presenters
------------------------------

[](#using-translator-in-presenters)

Add the TranslatorAdapter trait to your presenter:

```
use Drago\Localization\TranslatorAdapter;
```

The trait provides:

- persistent language parameter ($lang)
- automatic translator initialization
- template integration

Accessing the Current Language
------------------------------

[](#accessing-the-current-language)

You can access the currently set language using the following property:

```
$this->lang;
```

Getting Translator Instance
---------------------------

[](#getting-translator-instance)

To get the initialized translator for the current language:

```
$this->getTranslator()
```

Using Translations in Templates
-------------------------------

[](#using-translations-in-templates)

The translator is automatically registered in templates. Example usage in Latte:

```
{_"Hello, world!"}
{$label|translate}
```

Using Translator in Forms
-------------------------

[](#using-translator-in-forms)

To enable translations in forms, set the translator explicitly:

```
$form->setTranslator($this->getTranslator());
```

Routing for Language Switching
------------------------------

[](#routing-for-language-switching)

To support language prefixes, configure your routes accordingly:

```
$router->addRoute('[/]/', 'Presenter:action');
```

Switching Languages in Templates
--------------------------------

[](#switching-languages-in-templates)

You can switch languages by passing the lang parameter:

```
Czech
English
```

Notes
-----

[](#notes)

- Translator loads translations lazily on first use
- Translations are loaded once per request
- Missing keys return the original message

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance76

Regular maintenance activity

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~222 days

Total

13

Last Release

130d ago

Major Versions

v1.0.12 → v2.0.02026-01-08

PHP version history (6 changes)v1.0.0PHP &gt;=7.1

v1.0.5PHP &gt;=7.4

v1.0.6PHP &gt;=8.0

v1.0.8PHP &gt;=8.1

v1.0.10PHP &gt;=8.1 &lt;8.4

v1.0.11PHP &gt;=8.3 &lt;9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5998929?v=4)[Zdeněk Papučík](/maintainers/accgit)[@accgit](https://github.com/accgit)

---

Top Contributors

[![accgit](https://avatars.githubusercontent.com/u/5998929?v=4)](https://github.com/accgit "accgit (276 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")

---

Tags

nettetranslator

### Embed Badge

![Health badge](/badges/drago-ex-translator/health.svg)

```
[![Health](https://phpackages.com/badges/drago-ex-translator/health.svg)](https://phpackages.com/packages/drago-ex-translator)
```

###  Alternatives

[nette/nette

👪 Nette Framework - innovative framework for fast and easy development of secured web applications in PHP (metapackage)

1.6k2.8M335](/packages/nette-nette)[kdyby/translation

Integration of Symfony/Translation into Nette Framework

921.2M24](/packages/kdyby-translation)[contributte/translation

Symfony/Translation integration for Nette Framework.

771.8M37](/packages/contributte-translation)[nette/web-project

Nette: Standard Web Project

10991.8k](/packages/nette-web-project)[kdyby/autowired

Syntax sugar for working with services in Nette Framework

30885.7k9](/packages/kdyby-autowired)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
