twig/intl-extra
Twig Intl Extra adds internationalization helpers to Twig: look up country, currency, language, locale and timezone names, list country timezones, and format numbers, currencies, dates and times using ICU/Intl-style formatting.
twig/bridge or standalone) or Laravel Nova/Vue/Inertia where dynamic locale formatting is critical.intl extension (must be enabled). Laravel’s default stack already includes this, reducing friction.App::setLocale()). Requires discipline to avoid mixing template and application logic.{{ '2026-03-17'|date('long') }}).twig/bridge to integrate Twig with Laravel’s service container.Twig_ExtraExtension).setlocale() vs. Twig’s {{ 'en_US'|locale }}). Risk of inconsistent formatting.twig/intl-extra + twig/twig to the stack, increasing bundle size (~1MB).App::getLocale() vs. hardcoded Twig filters)?intl extension?Str::of() or Carbon handle 80% of needs?spatie/laravel-activitylog or laravel-notification-channels).
composer require twig/twig twig/intl-extra
$twig = new \Twig\Environment($loader);
$twig->addExtension(new \Twig\Extension\IntlExtension());
{{ __() }} or @lang with Twig filters where Intl-Extra adds value.$twig->addFunction(new \Twig\TwigFunction('app_locale', function() {
return app()->getLocale();
}));
php -m | grep intl). Laravel’s default php.ini usually includes it.twig/bridge may require version alignment.Twig\Cache\FilesystemCache).{{ date|date('long') }}).locale('xh') for Xhosa).twig/twig and twig/intl-extra to composer.json.intl extension (e.g., ICU version changes).config/app.php may need Twig service bindings.Twig_Error_Syntax).Twig\Error\LoaderError for template loading issues.{% if %} vs. @if).plural, select, number_format).{{ complex_date|date('full') }} in loops).twig.cache_warmer).Carbon objects to templates).intl extension is optimized (e.g., intl.use_exceptions=0 in php.ini).| Failure Point | Impact | Mitigation |
|---|---|---|
intl extension missing |
All Intl-Extra filters fail | Check php -m; use fallback logic. |
| Locale not supported | Silent failures or incorrect output | Validate locales; use app()->getFallbackLocale(). |
| Twig cache corruption | Broken templates | Clear cache (php artisan twig:clear). |
| Template syntax errors | 500 errors | Use @twig directives in Blade for debugging. |
| PHP 8.1+ incompatibility | Runtime errors | Pin versions in composer.json. |
How can I help you explore Laravel packages today?