LEMONADE Documentation

Documentation.

Fifteen chapters covering installation, project structure, application development, CLI and production deployment.

Chapter 13 of 15

Localization.

Store translations in file catalogs and resolve the locale primarily from the URL.

Translation catalogs

Catalogs follow app/Language/{locale}/{group}.php. Injected TranslatorInterface or $this->lang() reads keys in group.key form.

app/Language/en/messages.php
<?php

declare(strict_types=1);

return [
    'welcome' => 'Welcome to Lemonade.',
    'navigation.home' => 'Home',
];

Configure default, fallback, and supported locales in Localization.yaml. Missing keys are looked up in the fallback locale.

Localized URLs

localizedGroup() adds a localized route group variant. Generate links in views with $this->localizedUrl(); use an explicit application map when URL segments differ by language.

Localized routes and links
<?php

$router->localizedGroup(static function (Router $router): void {
    $router->getNamed(
        'home',
        '/',
        ControllerAction::for(HomeController::class, 'index'),
    );
});

?>
<!-- In a request-rendered view: -->
<h1><?= e($this->lang('messages.welcome')) ?></h1>
<a href="<?= e($this->localizedUrl('home')) ?>">Home</a>

The application takes the locale from the URL parameter and applies it through TranslatorInterface::setLocale() at the start of the request. The request renderer then exposes the same value through $this->currentLocale().

Detailed technical documentation on GitHub