lombokclarion / i18n
Explicit internationalization for LombokClarion: locale catalogs are plain PHP files listed in a manifest, never directory-scanned. Parameter interpolation, count-based pluralization, fallback locale.
v2.1.0
2026-08-08 17:25 UTC
Requires
- php: >=8.3
- lombokclarion/http: *
This package is auto-updated.
Last update: 2026-08-09 13:12:21 UTC
README
Translation loader and locale-detection middleware.
[READ-ONLY] This is a subtree split of the LombokClarion monorepo.
Do not send pull requests here — contribute to the main repository instead.
Install
composer require lombokclarion/i18n
Namespace
LombokClarion\I18n
What's Inside
| Class | Role |
|---|---|
Translator |
Loads .php translation files, resolves key → localized string |
DetectLocale |
Middleware: reads Accept-Language header → sets locale in RequestContext |
Usage
use LombokClarion\I18n\Translator; $translator = new Translator('resources/lang'); $translator->setLocale('id'); echo $translator->get('welcome'); // from resources/lang/id.php echo $translator->get('greeting', ['name' => 'Budi']); // "Halo, Budi"
Locale Detection Middleware
$router->group('/app', [DetectLocale::class], function (Router $r) { // All routes here auto-detect locale from Accept-Language });
Supported locales (24): ar, bn, de, en, es, fa, fr, hi, id, it, ja, ko, ms, nl, pl, pt, ru, sw, th, tr, uk, ur, vi, zh
License
Apache-2.0 — see LICENSE in the main repository.