intl-extra
Locale-aware internationalization filters for Twig templates
Repository Health
Technical Analysis
twig/intl-extra is an official Twig extension that adds internationalization (Intl) filters to your templates. It brings locale-aware formatting of numbers, currencies, dates, times, and lists directly into Twig, along with helpers that resolve human-readable country, currency, language, locale, and timezone names from their codes.
Built on top of Symfony’s Intl component and PHP’s intl extension, it lets template authors present data in the correct format for each user’s locale without writing PHP formatting logic, making it a staple for multilingual Symfony and Twig applications.
What You Get
- Locale-aware format_number, format_currency, format_datetime, format_date, and format_time filters
- Name-lookup filters for countries, currencies, languages, locales, and timezones
- A format_list filter that joins strings into a single locale-correct list
- A country_timezones filter returning timezone identifiers for a country code
Common Use Cases
- Displaying prices and numbers in the correct format for each user’s locale
- Rendering dates and times localized to the visitor’s language and region
- Showing human-readable country, currency, or language names from codes
Under The Hood
Architecture - The whole package is a single IntlExtension class in the Twig\Extra\Intl namespace that implements Twig’s ExtensionInterface. getFilters() registers each filter and maps it to a method that delegates to Symfony’s Intl helpers (Countries, Currencies, Languages, Locales, Timezones) and PHP’s IntlDateFormatter / NumberFormatter, caching formatter instances internally to avoid rebuilding them on every call.
Tech Stack - PHP 8.1+, depending on twig/twig (^3.13|^4.0) and symfony/intl (^5.4 through ^8.0), which in turn relies on PHP’s intl extension. Distributed via Composer with PSR-4 autoloading; there are no other runtime dependencies.
Code Quality - A compact, focused codebase (~32KB, one production class) maintained by the core Twig/Symfony team, with a dedicated Tests directory containing unit and integration tests run through the Symfony PHPUnit bridge. The code is consistent and idiomatic, following Twig extension conventions.
API Design - The developer experience is excellent: register the extension (automatic in Symfony) and the filters read naturally in templates, e.g. {{ price|format_currency(‘EUR’) }} or {{ date|format_datetime(‘medium’, ‘short’) }}. Each filter is documented on twig.symfony.com, and the filter names mirror their intent, keeping the learning curve minimal.
Used by 2 apps in this directory
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.