PHPackages                             phpdot/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. [Caching](/categories/caching)
4. /
5. phpdot/i18n

ActiveLibrary[Caching](/categories/caching)

phpdot/i18n
===========

Internationalization with ICU MessageFormat, pluggable loaders, PSR-16 caching.

v0.1.0(1mo ago)00MITPHPPHP &gt;=8.5

Since Jul 18Pushed 1mo agoCompare

[ Source](https://github.com/phpdot/i18n)[ Packagist](https://packagist.org/packages/phpdot/i18n)[ RSS](/packages/phpdot-i18n/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (21)Versions (9)Used By (0)

phpdot/i18n
===========

[](#phpdoti18n)

Internationalization built on ICU MessageFormat (via `ext-intl`): one syntax for interpolation, pluralization, and selection. Translations load through pluggable loaders (PHP arrays, JSON, or a chain), compiled maps are cached through any PSR-16 cache, and the translator implements the `PHPdot\Contracts\I18n\MessageTranslatorInterface` so the rest of the ecosystem depends only on the contract.

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Architecture](#architecture)
- [Testing](#testing)
- [License](#license)

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

[](#requirements)

RequirementConstraintPHP`>= 8.5``ext-intl``*``phpdot/contracts``^0.1``psr/simple-cache``^3.0``phpdot/container` is a dev-only suggestion — the `#[Config('i18n')]` / binding attributes are inert until a phpdot application reflects them.

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

[](#installation)

```
composer require phpdot/i18n
```

Usage
-----

[](#usage)

```
use PHPdot\I18n\I18nConfig;
use PHPdot\I18n\Translator;
use PHPdot\I18n\Loader\PhpArrayLoader;

$config = new I18nConfig(
    default: 'en',
    supported: ['en', 'ar', 'fr'],
    path: '/app/lang',
);

$translator = new Translator(
    loader: new PhpArrayLoader($config),
    cache: $cache,   // any PSR-16 implementation
    config: $config,
);

$translator->setLocale('ar_JO');
echo $translator->translate('messages.welcome', ['name' => 'Omar']);
```

### Translation files

[](#translation-files)

Keys are prefixed by filename, so `lang/en/messages.php` gives `messages.welcome`:

```
// lang/en/messages.php
return [
    'welcome' => 'Welcome, {name}!',
    'items' => '{count, plural, one {# item} other {# items}}',
];
```

`JsonLoader` reads the same shape from `.json` files; `ChainLoader` layers several loaders so later sources (e.g. database overrides) win. Every template is ICU MessageFormat — interpolation, `plural`, and `select` all share one syntax — and `ICUValidator` can check a template before it ships.

Architecture
------------

[](#architecture)

`Translator` resolves a key to its ICU template through the configured `LoaderInterface`, formats it with the current locale using `ext-intl`'s MessageFormatter, and caches the compiled per-language map in a PSR-16 cache. Unknown keys are recorded so missing translations can be audited.

 ```
graph TD
    APP["Application / Contracts MessageTranslatorInterface"]
    TRANSLATOR["Translatorresolve key → ICU template → format for locale"]
    LOADER["LoaderInterfacePhpArrayLoader / JsonLoader / ChainLoader"]
    CACHE["PSR-16 cachecompiled per-language maps"]
    ICU["ext-intl MessageFormatterinterpolation, plural, select"]

    APP --> TRANSLATOR
    TRANSLATOR --> LOADER
    TRANSLATOR --> CACHE
    TRANSLATOR --> ICU
```

      Loading Testing
-------

[](#testing)

```
composer install
composer test        # PHPUnit
composer analyse     # PHPStan, level max + strict rules
composer cs-check    # PHP-CS-Fixer
composer check       # All three
```

License
-------

[](#license)

MIT.

**This repository is a read-only mirror**, generated by CI from [phpdot/monorepo](https://github.com/phpdot/monorepo). [Pull requests](https://github.com/phpdot/monorepo/pulls)and [issues](https://github.com/phpdot/monorepo/issues) belong in the monorepo.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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 ~14 days

Recently: every ~25 days

Total

8

Last Release

32d ago

PHP version history (3 changes)v1.0.0PHP &gt;=8.3

v1.2.3PHP &gt;=8.4

v0.1.0PHP &gt;=8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/62e82421bda4b5d6ba9a47ba6d88caca060dcd0d1a2862f351f3a97657385db0?d=identicon)[phpdot](/maintainers/phpdot)

---

Top Contributors

[![phpdot](https://avatars.githubusercontent.com/u/252500?v=4)](https://github.com/phpdot "phpdot (11 commits)")[![o3AM](https://avatars.githubusercontent.com/u/252500?v=4)](https://github.com/o3AM "o3AM (1 commits)")

---

Tags

internationalizationi18nicutranslationpsr-16localemessageformat

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[tractorcow/silverstripe-fluent

Simple localisation for Silverstripe

90442.7k30](/packages/tractorcow-silverstripe-fluent)[skillshare/formatphp

Internationalize PHP apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.

7933.0k](/packages/skillshare-formatphp)[delight-im/i18n

Internationalization and localization for PHP

595.5k3](/packages/delight-im-i18n)[jrmajor/fluent

Fluent localization system for PHP

2918.4k7](/packages/jrmajor-fluent)[jrmajor/laravel-fluent

Fluent translations for Laravel

208.8k](/packages/jrmajor-laravel-fluent)

PHPackages © 2026

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