ez-php / i18n
Internationalisation module for the ez-php framework — file-based translations with dot-notation keys and locale fallback
2.4.2
2026-09-16 14:31 UTC
Requires
- php: ^8.5
- ez-php/contracts: ^2.0
Requires (Dev)
- ez-php/docker: ^2.0
- ez-php/testing-application: ^2.0
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.9
- 2.3.8
- 2.3.7
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.14.0
- 1.13.1
- 1.13.0
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.2
- 1.11.1
- 1.11.0
- 1.10.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.6
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.1
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
This package is auto-updated.
Last update: 2026-09-16 14:34:12 UTC
README
Internationalisation module for the ez-php framework — file-based translations with dot-notation keys and locale fallback.
Requirements
- PHP 8.5+
- ez-php/framework 0.*
Installation
composer require ez-php/i18n
Setup
Register the service provider:
$app->register(\EzPhp\I18n\TranslatorServiceProvider::class);
Add translation files under lang/{locale}/:
lang/
en/
messages.php → ['welcome' => 'Welcome, :name!']
de/
messages.php → ['welcome' => 'Willkommen, :name!']
Usage
$translator = $app->make(\EzPhp\I18n\Translator::class); echo $translator->get('messages.welcome', ['name' => 'Alice']); // Welcome, Alice! $translator->setLocale('de'); echo $translator->get('messages.welcome', ['name' => 'Alice']); // Willkommen, Alice!
Locale formatting
LocaleFormatter wraps PHP's ext-intl extension to format numbers, currencies, and dates in a locale-aware way:
use EzPhp\I18n\LocaleFormatter; $fmt = new LocaleFormatter('de_DE'); echo $fmt->number(1234567.89); // '1.234.567,89' echo $fmt->currency(9.99, 'EUR'); // '9,99 €' echo $fmt->date(new \DateTimeImmutable('2024-06-15')); // '15.06.2024' echo $fmt->dateTime(new \DateTimeImmutable('2024-06-15 14:30:00')); // '15.06.2024, 14:30:00'
Requires PHP's ext-intl extension.
License
MIT — Andreas Uretschnig