PHPackages                             cr0w/phrazor - 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. cr0w/phrazor

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

cr0w/phrazor
============

Minimal gettext-style i18n with ICU message formatting.

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

Since Mar 20Pushed 1mo agoCompare

[ Source](https://github.com/cr0w-digital/phrazor)[ Packagist](https://packagist.org/packages/cr0w/phrazor)[ RSS](/packages/cr0w-phrazor/feed)WikiDiscussions main Synced 1mo ago

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

// phrazor
==========

[](#-phrazor)

Minimal gettext-style i18n for PHP with ICU message formatting.

- Source patterns are the keys — no separate message IDs
- ICU `MessageFormatter` for pluralization, gender, and variable substitution
- Scanner CLI to extract patterns and keep locale files in sync
- Zero config for simple projects, fully configurable for complex ones

**Requirements:** PHP 8.2+, `ext-intl`

---

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

[](#installation)

```
composer require cr0w/phrazor
```

---

Basic usage
-----------

[](#basic-usage)

```
// Simplest case — returns the pattern if no translation found
echo t('Welcome');

// Variable substitution (requires ext-intl)
echo t('Welcome, {name}', ['name' => 'Alice']);

// Pluralization
echo t('{count, plural,
    =0 {No items}
    one {# item}
    other {# items}
}', ['count' => 3]);

// Gender
echo t('{gender, select,
    male {He liked this}
    female {She liked this}
    other {They liked this}
}', ['gender' => 'female']);

// Canonical namespaced call
echo \phrazor\t('Welcome, {name}', ['name' => 'Alice']);
```

The global `t()` alias is registered automatically at autoload time. If `t()` is already defined in your project, phrazor will issue an `E_USER_NOTICE` and you can use `\phrazor\t()` instead.

---

Locale files
------------

[](#locale-files)

Locale files live in your i18n directory and return a plain PHP array. The source pattern is the key, the translation is the value.

```
// i18n/fr_FR.php
