PHPackages                             slendium/localization - 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. slendium/localization

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

slendium/localization
=====================

Framework-agnostic interfaces for localization.

v0.6.0(5mo ago)0731MITPHPPHP ^8.4

Since Jan 31Pushed 4mo ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (7)Used By (1)

Slendium/Localization
=====================

[](#slendiumlocalization)

A framework-agnostic PHP library for localization. Includes:

- PHPDocs with type hints for static analyzers
- Works with PHP-native standards ([RFC 4646, CLDR](https://www.php.net/manual/en/class.locale.php))

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

[](#installation)

Requires **PHP &gt;= 8.4**. Simply run `composer install slendium/localization` to add it to your project.

Example
-------

[](#example)

Create a domain-specific object with a translatable `$name` property.

```
class Product {
  /** @var Localizable */
  public Localizable $name;
}
```

Now consume this object in an `EmailGenerator` template.

```
class OrderEmailGenerator extends EmailGenerator {

  public function __construct(
    /** @var list */
    private array $products
  ) { }

  #[Override]
  public function generateBody(): iterable {
    yield $this->getSalutation($this->getCustomerName()); // combines localizable information with a customer name
    yield '';
    yield $this->translate('thanks_for_ordering'); // a Localizable from a static dictionary
    yield from [ '', $this->translate('product_category'), '' ];
    foreach ($this->products as $product) {
      yield from [ '', $product->name, '' ]; // $product->name is a localizable
    }
    yield '';
    yield $this->getSignature(); // another localizable
  }
}
```

The email generator can simply return a mix of markup and localizables to be converted to their translated equivalents at a later stage.

Motivation
----------

[](#motivation)

There are different ways of doing localization in PHP (array dictionaries, [gettext](https://www.php.net/manual/en/book.gettext.php), framework-specific implementations, etc.). Sometimes end-users can enter their own translations on a per-object basis - for example, using a database table. Code that is responsible for producing a locale-specific output (such as an HTML page, a JSON object, a PDF, an e-mail, etc.), or other libraries that want to work with localizable objects, should not need to know about the underlying dictionary implementation of such objects.

Pluralization is not part of this library, for now.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance75

Regular maintenance activity

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Every ~80 days

Recently: every ~88 days

Total

6

Last Release

163d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8cb32e80bc8745da0070b0df3e42a7a4d0de1064a34bd32eafc341437f2b193?d=identicon)[packagist.uch8@frisiapp.com](/maintainers/packagist.uch8@frisiapp.com)

---

Top Contributors

[![cfahner](https://avatars.githubusercontent.com/u/3216275?v=4)](https://github.com/cfahner "cfahner (38 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/slendium-localization/health.svg)

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

###  Alternatives

[smarty-gettext/smarty-gettext

Gettext plugin enabling internationalization in Smarty Package files

752.5M8](/packages/smarty-gettext-smarty-gettext)[devaslanphp/auto-translate

Auto generate translation JSON files

6627.3k](/packages/devaslanphp-auto-translate)

PHPackages © 2026

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