PHPackages                             tonop/translatte - 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. tonop/translatte

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

tonop/translatte
================

Translator for Nette framework

028PHP

Since Feb 17Pushed 1y agoCompare

[ Source](https://github.com/tonop01/translatte)[ Packagist](https://packagist.org/packages/tonop/translatte)[ RSS](/packages/tonop-translatte/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Translatte
==========

[](#translatte)

[![Build Status](https://camo.githubusercontent.com/9fd11f9059367dfa60f2c2edb3d4b1aa76c59fdfab98e83b5f0c932b668cdcbf/68747470733a2f2f7472617669732d63692e6f72672f65666162726963612d7465616d2f7472616e736c617474652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/efabrica-team/translatte)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3182a3e7ee63e496f11156e4c6be33423a06ab8105dd345ad5415f07a0b8190b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f65666162726963612d7465616d2f7472616e736c617474652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/efabrica-team/translatte/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/0e9b90ddfe8ea720f2a9d06b82b9ffb41962e229d0cf03abe8120323cbb7c0c4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f65666162726963612d7465616d2f7472616e736c617474652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/efabrica-team/translatte/?branch=master)

Translator for Nette framework.

Usage
-----

[](#usage)

```
use Efabrica\Translatte\Translator;
use Efabrica\Translatte\Resource\NeonDirectoryResource;

// Create new translator with default language
$translator = new Translator('sk_SK');

// Register new resources where translations are stored
$translator->addResource(new NeonDirectoryResource([__DIR__ . '/lang', __DIR__ . '/another/lang']));
$translator->addResource(new NeonResource(__DIR__ . '/dictionary.sk_SK.neon', 'sk_SK'));

// Translate basic string
$translator->translate('dictionary.forms.error']);

// Translate with pluralization
$translator->translate('key', 10);

// Translate with parameters
$translator->translate('key', ['name' => 'Peter']);

// Translate with pluralization and parameters
$translator->translate('key', 10, ['page' => 'login']);

// Select translation language on the fly
$translator->translate('key', 1, [], 'en_US');
```

### Nette extension

[](#nette-extension)

```
extensions:
	translation: Efabrica\Translatte\Bridge\Nette\TranslationExtension

# Minimal configuration
translation:
    default: 'sk_SK' # mandatory

# Full configuration
translation:
    default: 'sk_SK' # mandatory
    fallback: # optional
        - 'en_US'
        - 'en_UK'
    dirs:
        - %appDir%/lang
    cache: Efabrica\Translatte\Cache\NullCache() # optional
    resolvers: # optional
        - Efabrica\Translatte\Resolver\StaticResolver('sk_Sk')
    resources: # optional
        - Efabrica\Translatte\Resource\NeonDirectoryResource(%appDir%/localize)

```

### Syntactic sugar

[](#syntactic-sugar)

**dictionary.sk\_SK.neon**:

```
cart:
    products_in_cart: 'V košíku je jeden produkt|V košíku sú %count% produkty|V košíku je %count% produktov'

```

**Source: src/PluralForm.php**

```
Example of count syntax:
sk: '1|2-4|0,5-Inf'
cz: '1|2-4|0,5-Inf'
en: '1|0,2-Inf'

Example of special count syntax (https://symfony.com/doc/3.1/components/translation/usage.html#pluralization):
en: '[-Inf,-10]big negative count|]-10,0[negative count|{0}zero count|{1}one count|{2,3,4}two,three,four count|]4,Inf]more than four count'
sk: '[-Inf,-10]veľký negatívny počet|]-10,0[negatívny počet|{0}nula počet|{1}jedna počet|{2,3,4}dva,tri,štyri počet|]4,Inf]viac ako štyri počet'

```

**index.php**:

```
// Translator setup
$translator = ...

// To params array is set count variable
$translator->translate('dictionary.cart.products_in_cart', 2); // V košíku sú 2 produkty

// Param count from params array is used to select right plural form
$translator->translate('dictionary.cart.products_in_cart', ['count' => 2]); // V košíku sú 2 produkty

// If we set both params nothing is override
$translator->translate('dictionary.cart.products_in_cart', 10, ['count' => 2]); // V košíku je 2 produktov

```

Main classes
------------

[](#main-classes)

### Resolver

[](#resolver)

Resolves which language has translator to use.
Available resolvers:

- **StaticResolver** - Resolves to given static lang.
- **ChainResolver** - Multiple resolvers can be registered to this resolver. First resolver which returns non empty string is used.

### Resource

[](#resource)

Represents "storage" with translation strings. It can be anything - directory with translation files, database, redis or external api call.
Available resources:

- **NeonResource** - One neon file.
- **NeonDirectoryResource** - Multiple directories in which resource search neon files in format "{prefix}.{lang}.neon".

### Cache

[](#cache)

Used for cache generated directory.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29866948?v=4)[Anton Pôbiš](/maintainers/tonop01)[@tonop01](https://github.com/tonop01)

---

Top Contributors

[![ricco24](https://avatars.githubusercontent.com/u/1409647?v=4)](https://github.com/ricco24 "ricco24 (14 commits)")[![tonop01](https://avatars.githubusercontent.com/u/29866948?v=4)](https://github.com/tonop01 "tonop01 (12 commits)")[![lulco](https://avatars.githubusercontent.com/u/9377319?v=4)](https://github.com/lulco "lulco (4 commits)")

### Embed Badge

![Health badge](/badges/tonop-translatte/health.svg)

```
[![Health](https://phpackages.com/badges/tonop-translatte/health.svg)](https://phpackages.com/packages/tonop-translatte)
```

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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