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

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

cracksalad/i18n
===============

PHP library to properly handle internationalization, but in a stateless fashion - no gettext()!

0.1.2(1y ago)02.5k↑28.9%MITPHPPHP &gt;=8.0

Since Aug 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/cracksalad/i18n-php)[ Packagist](https://packagist.org/packages/cracksalad/i18n)[ RSS](/packages/cracksalad-i18n/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

i18n
====

[](#i18n)

[![Latest Stable Version](https://camo.githubusercontent.com/d100793153a113f3e032fbe6638b9351070ba5a6df67d13883a72d0cc55a1b59/68747470733a2f2f706f7365722e707567782e6f72672f637261636b73616c61642f6931386e2f76)](https://packagist.org/packages/cracksalad/i18n)[![Total Downloads](https://camo.githubusercontent.com/6b3e1e835c27e208b4ae40b8a0ef815b64510d4ffc33a5a8dd514acd0b9b46f5/68747470733a2f2f706f7365722e707567782e6f72672f637261636b73616c61642f6931386e2f646f776e6c6f616473)](https://packagist.org/packages/cracksalad/i18n)[![License](https://camo.githubusercontent.com/96ff086746dee98fcbe54d3b3a03f3f114098ea862e8fb4a09ee7e3e07c6a24d/68747470733a2f2f706f7365722e707567782e6f72672f637261636b73616c61642f6931386e2f6c6963656e7365)](https://packagist.org/packages/cracksalad/i18n)[![PHP Version Require](https://camo.githubusercontent.com/f951aa99bb230481aaf1250d53048c2eef6e67e12addf27649b883cc9a385c6d/68747470733a2f2f706f7365722e707567782e6f72672f637261636b73616c61642f6931386e2f726571756972652f706870)](https://packagist.org/packages/cracksalad/i18n)[![Psalm Type Coverage](https://camo.githubusercontent.com/b09785e22ea7ec7d82e8f51651ab226ba625b327746ce130d556aee23e277450/68747470733a2f2f73686570686572642e6465762f6769746875622f637261636b73616c61642f6931386e2d7068702f636f7665726167652e737667)](https://packagist.org/packages/cracksalad/i18n)

This library depends on [php-gettext/Gettext](https://github.com/php-gettext/Gettext) and is inspired by [delight-im/PHP-I18N](https://github.com/delight-im/PHP-I18N) as well as [gettext](https://www.php.net/manual/en/function.gettext).

Although this library is mainly compatible with delight-im/PHP-I18N, there are some differences. The main difference is that this library does not use `gettext()` and `setlocale()` but instead is stateless and thereby supports independent (concurrent) request handling as it is done with [PSR-15: HTTP Handlers](https://www.php-fig.org/psr/psr-15/) and [OpenSwoole](https://openswoole.com/). Another difference is that this library does not try to detect the users language based on the domain and path of the current URL or on some cookie.

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

[](#installation)

NOTE: This library requires PHP 8.0+

```
composer require cracksalad/i18n
```

Usage
-----

[](#usage)

First you need to create translation files (e.g. using `xgettext` in bash) in a folder structure like this:

```
locale/
├─ en/
│  ├─ LC_MESSAGES/
│  │  ├─ messages.mo
│  │  ├─ messages.po
├─ de/
│  ├─ LC_MESSAGES/
│  │  ├─ messages.mo
│  │  ├─ messages.po

```

```
use Cracksalad\I18n\I18n;

$i18n = I18n::load('en');

$i18n->_('Hello world!');
// -> Hello world!

// format (using sprintf() internally)
$i18n->_f('%d items saved', 42);
// -> 42 items saved

// ICU MessageFormat
$i18n->_fe('I first published this library on {0, date, short}', 1692982322);
// -> I first published this library on 8/23/23

// singular vs. plural with format
$i18n->_pf('%d item saved', '%d items saved', 42);
// -> 42 items saved
$i18n->_pf('%d item saved', '%d items saved', 1);
// -> 1 item saved
```

License
-------

[](#license)

This library is licensed under the MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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 ~322 days

Total

2

Last Release

721d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/28577589?v=4)[cracksalad](/maintainers/cracksalad)[@cracksalad](https://github.com/cracksalad)

---

Top Contributors

[![cracksalad](https://avatars.githubusercontent.com/u/28577589?v=4)](https://github.com/cracksalad "cracksalad (10 commits)")

---

Tags

i18nphpphp8psr-15intli18ntranslationgettextlocale

### Embed Badge

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

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

###  Alternatives

[gettext/gettext

PHP gettext manager

70232.6M118](/packages/gettext-gettext)[fightbulc/moment

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

9683.4M13](/packages/fightbulc-moment)[aplus/language

Aplus Framework Language Library

2391.7M15](/packages/aplus-language)[delight-im/i18n

Internationalization and localization for PHP

595.4k3](/packages/delight-im-i18n)[om/potrans

Command line tool for translate Gettext with Google Translator API or DeepL API

10520.2k9](/packages/om-potrans)[skillshare/formatphp

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

8032.4k](/packages/skillshare-formatphp)

PHPackages © 2026

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