Intl Filters
Internationalization filters using PHP's Intl extension. These filters are only available when the PHP intl extension is loaded.
Name Lookups
| Filter | Arguments | Description |
|---|---|---|
country_name | locale | Get country name from code |
currency_name | locale | Get currency name from code |
currency_symbol | locale | Get currency symbol from code |
language_name | locale | Get language name from code |
locale_name | locale | Get locale name from code |
timezone_name | locale | Get timezone name from identifier |
All filters accept an optional locale argument (defaults to WordPress locale).
{{ 'US'|country_name }} <!-- United States -->
{{ 'FR'|country_name }} <!-- France -->
{{ 'FR'|country_name('fr_FR') }} <!-- France (in French) -->
{{ 'USD'|currency_name }} <!-- US Dollar -->
{{ 'EUR'|currency_name }} <!-- Euro -->
{{ 'USD'|currency_symbol }} <!-- $ -->
{{ 'EUR'|currency_symbol }} <!-- € -->
{{ 'en'|language_name }} <!-- English -->
{{ 'fr'|language_name }} <!-- French -->
{{ 'fr'|language_name('fr_FR') }} <!-- français -->
{{ 'en_US'|locale_name }} <!-- English (United States) -->
{{ 'fr_FR'|locale_name }} <!-- French (France) -->
{{ 'Europe/Paris'|timezone_name }} <!-- Central European Time -->
{{ 'America/New_York'|timezone_name }} <!-- Eastern Time -->
Number Formatting
| Filter | Arguments | Description |
|---|---|---|
format_currency | currency, locale | Format as currency |
format_number | style, locale, attrs | Format number |
format_currency
Arguments:
currency— Currency code (default:'USD')locale— Locale code (default: WordPress locale)
{{ 1234.56|format_currency('USD') }} <!-- $1,234.56 -->
{{ 1234.56|format_currency('EUR') }} <!-- €1,234.56 -->
{{ 1234.56|format_currency('EUR', 'de_DE') }} <!-- 1.234,56 € -->
{{ 1234.56|format_currency('GBP', 'en_GB') }} <!-- £1,234.56 -->
format_number
Arguments:
style— Format style (default:'decimal')locale— Locale code (default: WordPress locale)attrs— Additional formatter attributes (optional)
Style options:
'decimal'— Standard decimal number'currency'— Currency format'percent'— Percentage format'scientific'— Scientific notation'spellout'— Number spelled out in words'ordinal'— Ordinal format (1st, 2nd, 3rd)'duration'— Duration format
{{ 1234.56|format_number }} <!-- 1,234.56 -->
{{ 1234.56|format_number('decimal') }}
{{ 0.75|format_number('percent') }} <!-- 75% -->
{{ 1234|format_number('spellout') }} <!-- one thousand two hundred thirty-four -->
{{ 3|format_number('ordinal') }} <!-- 3rd -->
Date/Time Formatting
| Filter | Arguments | Description |
|---|---|---|
format_date | dateFormat, locale, pattern, timezone | Format date |
format_time | timeFormat, locale, pattern, timezone | Format time |
format_datetime | dateFormat, timeFormat, locale, pattern, timezone | Format date and time |
Format options:
'none'— No output'short'— Short format'medium'— Medium format (default)'long'— Long format'full'— Full format
format_date
{{ post.date|format_date }} <!-- Jan 15, 2024 -->
{{ post.date|format_date('short') }} <!-- 1/15/24 -->
{{ post.date|format_date('medium') }} <!-- Jan 15, 2024 -->
{{ post.date|format_date('long') }} <!-- January 15, 2024 -->
{{ post.date|format_date('full') }} <!-- Monday, January 15, 2024 -->
{{ post.date|format_date('long', 'fr_FR') }} <!-- 15 janvier 2024 -->
format_time
{{ post.date|format_time }} <!-- 2:30:00 PM -->
{{ post.date|format_time('short') }} <!-- 2:30 PM -->
{{ post.date|format_time('medium') }} <!-- 2:30:00 PM -->
{{ post.date|format_time('long') }} <!-- 2:30:00 PM EST -->
format_datetime
{{ post.date|format_datetime }}
{{ post.date|format_datetime('medium', 'short') }}
{{ post.date|format_datetime('long', 'short', 'fr_FR') }}
Common Patterns
Localized currency display
{{ product.price|format_currency('USD') }}
Localized date
{{ post.date|format_date('long') }}
Country selector label
{{ country_code|country_name }}