Search by

phpaml / i18n

MR-C0DE

JSON-first internationalization for PHPAML and AML View.

v0.1.0-beta.1 2026-08-19 15:01 UTC

This package is auto-updated.

Last update: 2026-08-26 13:04:45 UTC


README

JSON-first internationalization for PHPAML and AML View.

Status: 0.1.0-beta.1. The translation runtime, locale resolver, fallback behavior, plural forms, and CLI workflow are available for public testing.

Documentation française · PHPAML CLI · AML View

Why PHPAML i18n?

Keep translations in small, nested JSON files and use predictable dot keys from PHP, AML View, or generated applications. PHPAML configures the package for you, while standalone PHP projects can initialize it directly.

  • nested JSON catalogs organized by locale and feature;
  • variable interpolation and one / other plural forms;
  • explicit fallback locale with diagnosable missing keys;
  • locale selection from routes, cookies, or Accept-Language;
  • CLI commands to add, validate, inspect, and select locales;
  • no external service or runtime dependency.

Install

aml install i18n

Or install the package directly:

composer require phpaml/i18n:^0.1@beta

Five-minute example

Translations live under src/locales/{locale}. Every nested JSON path becomes a dot key:

src/locales/fr/pages/home.json → pages.home.title
use AML\I18n\I18n;
use function AML\I18n\t;

I18n::configure(__DIR__ . '/locales', 'fr', 'en');
echo t('pages.home.welcome', ['name' => 'André']);
echo trans_choice('pages.home.tasks', 3);

aml install i18n configures the translator automatically in a PHPAML application. Files can be nested freely below each locale. Missing keys fall back to APP_FALLBACK_LOCALE, then return the key itself so the interface remains diagnosable.

aml i18n:add es
aml i18n:check
aml i18n:missing fr
aml i18n:set-default en

Plural forms use one and other keys. LocaleResolver can select a supported locale from a route, cookie or Accept-Language header while always returning a declared locale.

Platform relationship

PHPAML CLI
  └─ installs and configures PHPAML i18n
       ├─ PHPAML Framework controllers and APIs
       ├─ AML View pages and components
       └─ standalone PHP applications

Tests

composer test

License

PHPAML i18n is open-source software licensed under the MIT License.