phpmyadmin/twig-i18n-extension
Twig extension that adds i18n helpers for phpMyAdmin and other Twig-based apps. Provides translation-related functions/filters to integrate localization into templates with minimal setup and overhead.
twig-laravel or custom integration).Illuminate\Support\Facades\Lang and Blade directives (@lang, @choice). This package is not a drop-in replacement but could complement or replace parts of Laravel’s i18n if Twig is the primary templating engine.twig-laravel package (spatie/twig-laravel) or manual Twig setup..po/.json) are structured for Twig’s syntax (e.g., {{ 'message'|trans }}).App::setLocale() with Twig’s i18n extension.gettext).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Twig-Blade Collision | High | Isolate Twig functions (e.g., twig_trans vs. Blade’s @lang). |
| Laravel i18n Overlap | Medium | Deprecate redundant Blade directives if Twig is primary. |
| Translation File Format | Medium | Ensure .json/.po files match Twig’s expected structure. |
| Fork Maintenance | Low | Monitor phpMyAdmin’s upstream for updates; fork if critical fixes are needed. |
| Dependency Bloat | Low | Only pull in Twig if absolutely necessary (evaluate Blade’s i18n sufficiency first). |
lang files, gettext, or custom)? Will this package require a migration?App::setLocale()?i18next) instead.Lang::get(), etc.).spatie/twig-laravel and configure Twig as a service provider.// config/twig.php
'extensions' => [
TwigI18nExtension::class,
],
class TwigI18nAdapter
{
public function __construct(private App $app) {}
public function getLocale(): string
{
return $this->app->getLocale();
}
}
$twig->addExtension(new TwigI18nExtension(new TwigI18nAdapter()));
@lang('key')) with Twig equivalents:
{{ 'key'|trans }}
{{ 'key'|trans({'count': 5}) }}
{{ 'item'|transchoice(count) }}
{{ date|date('long') }}
| Component | Compatibility Notes |
|---|---|
| Laravel 10/11 | Tested with last release (2025-09-27); check for PHP 8.2+ support. |
| Twig 3.x | Required; ensure spatie/twig-laravel is compatible. |
| Translation Files | Prefers .po/.json; may need conversion from Laravel’s .php arrays. |
| Middleware | Works with Laravel’s locale middleware (e.g., SetLocaleMiddleware). |
Twig_Error_Syntax).view.cache config.{{ item.name|trans }} in a large collection).How can I help you explore Laravel packages today?