ez-php/i18n

Internationalisation module for the ez-php framework — file-based translations with dot-notation keys and locale fallback

Maintainers

Package info

github.com/ez-php/i18n

pkg:composer/ez-php/i18n

Statistics

Installs: 113

Dependents: 2

Suggesters: 1

Stars: 0

Open Issues: 0

0.4.1 2026-03-17 21:03 UTC

This package is auto-updated.

Last update: 2026-03-17 23:54:08 UTC


README

Internationalisation module for the ez-php framework — file-based translations with dot-notation keys and locale fallback.

CI

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!

License

MIT — Andreas Uretschnig