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: 5

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-03-15 03:47 UTC

This package is auto-updated.

Last update: 2026-03-15 04:17:58 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 ^1.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