PHPackages                             eufony/i18n - 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. eufony/i18n

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

eufony/i18n
===========

A simple but naive approach to token-based internationalization.

v1.x-dev(2y ago)06LGPL-3.0-or-laterPHPPHP ^8.1

Since Feb 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/eufony/i18n)[ Packagist](https://packagist.org/packages/eufony/i18n)[ RSS](/packages/eufony-i18n/feed)WikiDiscussions v1.x Synced 1mo ago

READMEChangelogDependencies (2)Versions (1)Used By (0)

The Eufony I18N Package
=======================

[](#the-eufony-i18n-package)

 [ ![Packagist Downloads](https://camo.githubusercontent.com/75c89de218e06e403198d8d66947cfbc78208bb6abfeb8a5264b84000b2a3e35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6575666f6e792f6931386e3f6c6162656c3d5061636b6167697374253230446f776e6c6f616473) ](https://packagist.org/packages/eufony/i18n) [ ![GitHub Stars](https://camo.githubusercontent.com/41bbcf43d762afd361a000acd24f9dd9f1922d499b3ad359af5dc91ce6271c17/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6575666f6e792f6931386e3f6c6162656c3d4769744875622532305374617273) ](https://github.com/eufony/i18n) [ ![Issues](https://camo.githubusercontent.com/c282a0b29244690feadd73f7e0fad7578b29991e8a4736b8affc0fef06c3a1bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6575666f6e792f6931386e2f6f70656e3f6c6162656c3d497373756573) ](https://github.com/eufony/i18n/issues)
 [ ![License](https://camo.githubusercontent.com/99163e668e9e1782eeb9a856e7ffb144e0764089d4c3fd55444722f8a24d5734/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6575666f6e792f6931386e3f6c6162656c3d4c6963656e7365) ](https://github.com/eufony/i18n#license) [ ![Community Built](https://camo.githubusercontent.com/db7f0b0f807877959a4badf1f8b12ae274bdf86899e95fc41e39aefb6ba5cc1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616465253230776974682d2545322539442541342d726564) ](https://github.com/eufony/i18n#contributing)

*eufony/i18n provides an easy-to-use but limited token-based approach to internationalization.*

*eufony/i18n* is a PHP library that allows defining and retrieving translated messages, called tokens. It provides a common interface for fetching tokens from different backends; with the explicit goal of providing a naive approach to varying grammatical rules, which is simpler than a more complete system such as GNU [`gettext`](https://www.gnu.org/software/gettext/).

Interested? [Here's how to get started.](#getting-started)

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

*eufony/i18n* is released as a [Packagist](https://packagist.org/) package and can be easily installed via [Composer](https://getcomposer.org/) with:

```
composer require "eufony/i18n:v1.x-dev"

```

> **Warning**: This package ***does not have any stable releases*** yet (not even a v0.x pre-release) and is currently ***unstable***. Expect frequent breaking changes and instability!

### Basic Usage

[](#basic-usage)

*eufony/i18n* provides two main classes to provide translation facilities: `Stores` and a `Translator`. Stores provide the actual `Tokens` that contain the translated messages. The `Translator` class acts as a front-end to using a store. To get started, choose a store implementation and pass it to a new translator, like so:

```
$store = /* ... */;
$translator = new Translator($store);
```

Out of the box, *eufony/i18n* provides two different store implementations:

```
// Fetch tokens from PHP arrays
// You could also for example parse this array from a JSON string
$store = new ArrayStore(["greetings.weather.good" => ["en" => "...", "de" => "...", "ru" => "..."]]);
$store = ArrayStore::fromJSON(File::read("extras/i18n/tokens.json"));  // `File` requires `eufony/filesystem`

// Fetch tokens from an SQL database using the `eufony/dbal` abstraction layer
$connection = new Connection(/* ... */);  // a `Connection` instance from `eufony/dbal`
$store = new SQLStore($connection);
```

Once the translator is initialized, you can start using it to translate messages or fetch tokens. Tokens are pre-translated messages that have been fed into the store, whereas translations may happen on-the-fly depending on the store implementation.

```
$greeting = $translator->translate("Hello, {user}.", ["en" => "de"]);  // if we only need a single target language
$greeting = $translator->translate("Hello, {user}.", ["en" => ["de", "ru"]]);  // for multiple target languages
$weather = $translator->token("greetings.weather.good");

// Once we have our tokens, we can use `get()` to extract the messages in the target languages
echo $greeting->interpolate(["user" => "Euphie"])->get("de");
echo $weather->get("de");
```

The constructor of the `Translator` class can also take an option `preferredLanguage` parameter, which will specify a default translation language. You can use this to simplify some of these calls if you already know the target language beforehand.

```
$translator = new Translator($store, preferredLanguage: "de");

// Now, we can assume the target language to be the preferred language by default
// But we can still override it for specific situations like above
$greeting = $translator->translate("Hello, {user}.", "en");
$weather = $translator->token("greetings.weather.good");

// If the preferred language is set, tokens can be converted to strings automatically
// No more need to call `get()` every time
echo $greeting->interpolate(["user" => "Euphie"]);
echo $weather;
```

Contributing
------------

[](#contributing)

Found a bug or a missing feature? You can report it over at the [issue tracker](https://github.com/eufony/i18n/issues).

License
-------

[](#license)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see .

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

819d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b73d2ffc86da306523c3c4fb19e002ba203ed2819b14db27d7b510bb58b2c3d?d=identicon)[ahgencer](/maintainers/ahgencer)

---

Top Contributors

[![ahgencer](https://avatars.githubusercontent.com/u/33004442?v=4)](https://github.com/ahgencer "ahgencer (13 commits)")

---

Tags

eufonyi18nl10nphptranslationi18nl10ntranslationeufony

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eufony-i18n/health.svg)

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

###  Alternatives

[loco/loco

Loco SDK for PHP, including REST API client

19626.8k4](/packages/loco-loco)[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[fisharebest/localization

A lightweight localization database and translation tools, with data from the CLDR, IANA, ISO, etc.

3191.1k2](/packages/fisharebest-localization)[delight-im/i18n

Internationalization and localization for PHP

625.2k3](/packages/delight-im-i18n)[mediawiki/translate

The only standard solution to translate any kind of text with an avant-garde web interface within MediaWiki, including your documentation and software

457.9k](/packages/mediawiki-translate)[jrmajor/fluent

Fluent localization system for PHP

2716.9k5](/packages/jrmajor-fluent)

PHPackages © 2026

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