intl-extra

Locale-aware internationalization filters for Twig templates

Library
Composer
vv3.26.0
360stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity52
Maintenance32
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture80
Code Quality85
Innovation72
Learning Curve88

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search