Const
The numeric amount to format
The currency code (e.g., 'USD', 'EUR', 'JPY')
The locale to use for formatting (default: user's locale)
Additional Intl.NumberFormat options for customization
The formatted currency string
InternationalizationUtils.formatCurrency(99.99, 'USD', 'en-US'); // "$99.99"
InternationalizationUtils.formatCurrency(99.99, 'EUR', 'fr-FR'); // "99,99 €"
InternationalizationUtils.formatCurrency(1234.56, 'JPY', 'ja-JP'); // "¥1,235"
Formats a date according to the specified locale and formatting options.
The date to format (Date object, timestamp, or date string)
The locale to use for formatting (default: user's locale)
Intl.DateTimeFormat options for customization
The formatted date string
InternationalizationUtils.formatDate(new Date(), 'en-US'); // "1/1/2024"
InternationalizationUtils.formatDate(new Date(), 'fr-FR', { dateStyle: 'full' }); // "lundi 1 janvier 2024"
InternationalizationUtils.formatDate(Date.now(), 'de-DE', { year: 'numeric', month: 'long' }); // "Januar 2024"
Formats a date using a specific pattern string for custom date formats.
The date to format (Date object, timestamp, or date string)
The format pattern string (e.g., 'YYYY-MM-DD', 'DD/MM/YYYY')
The locale to use (default: user's locale)
The formatted date string according to the pattern
InternationalizationUtils.formatDateWithPattern(new Date(), 'YYYY-MM-DD'); // "2024-01-01"
InternationalizationUtils.formatDateWithPattern(new Date(), 'DD/MM/YYYY'); // "01/01/2024"
InternationalizationUtils.formatDateWithPattern(new Date(), 'YYYY-MM-DD HH:mm:ss'); // "2024-01-01 14:30:45"
Formats a list of items according to locale-specific list formatting rules.
Array of strings to format into a list
The locale to use for formatting (default: user's locale)
ListFormat options for type and style
Optional
type?: "conjunction" | "disjunction" | "unit"The type of list: 'conjunction' (and), 'disjunction' (or), or 'unit'
Optional
style?: "short" | "long" | "narrow"The style: 'long', 'short', or 'narrow'
The formatted list string
InternationalizationUtils.formatList(['apple', 'banana', 'orange'], 'en-US'); // "apple, banana, and orange"
InternationalizationUtils.formatList(['red', 'blue'], 'en-US', { type: 'disjunction' }); // "red or blue"
InternationalizationUtils.formatList(['Jan', 'Feb', 'Mar'], 'fr-FR'); // "Jan, Feb et Mar"
Formats a number according to the specified locale and formatting options.
The number to format
The locale to use for formatting (default: user's locale)
Intl.NumberFormat options for customization
The formatted number string
InternationalizationUtils.formatNumber(1234.56, 'en-US'); // "1,234.56"
InternationalizationUtils.formatNumber(1234.56, 'fr-FR'); // "1 234,56"
InternationalizationUtils.formatNumber(0.75, 'en-US', { style: 'percent' }); // "75%"
Determines the plural rule category for a given count according to locale rules.
The number to determine plural category for
The locale to use for plural rules (default: user's locale)
Intl.PluralRules options
The plural category: 'zero', 'one', 'two', 'few', 'many', or 'other'
InternationalizationUtils.formatPlural(0, 'en-US'); // "other"
InternationalizationUtils.formatPlural(1, 'en-US'); // "one"
InternationalizationUtils.formatPlural(2, 'en-US'); // "other"
InternationalizationUtils.formatPlural(1, 'ru-RU'); // "one"
Formats a relative time string (e.g., "2 hours ago", "in 3 days") for a given date.
The date to format relative to now (Date object, timestamp, or date string)
The locale to use for formatting (default: user's locale)
Intl.RelativeTimeFormat options
The formatted relative time string
const now = new Date();
const anHourAgo = new Date(now.getTime() - 3600000);
InternationalizationUtils.formatRelativeTime(anHourAgo, 'en-US'); // "1 hour ago"
const tomorrow = new Date(now.getTime() + 86400000);
InternationalizationUtils.formatRelativeTime(tomorrow, 'en-US'); // "in 1 day"
Gets the localized display name for a calendar system.
The calendar code (e.g., 'gregory', 'buddhist', 'islamic')
The locale to use for formatting (default: user's locale)
Additional DisplayNames options for customization
The localized calendar display name
InternationalizationUtils.getCalendarDisplayName('gregory', 'en-US'); // "Gregorian Calendar"
InternationalizationUtils.getCalendarDisplayName('buddhist', 'th-TH'); // "ปฏิทินพุทธ"
InternationalizationUtils.getCalendarDisplayName('islamic', 'ar-SA'); // "التقويم الهجري"
Gets the localized display name for a currency.
The currency code (e.g., 'USD', 'EUR', 'JPY')
The locale to use for formatting (default: user's locale)
Additional DisplayNames options for customization
The localized currency display name
InternationalizationUtils.getCurrencyDisplayName('USD', 'en-US'); // "US Dollar"
InternationalizationUtils.getCurrencyDisplayName('EUR', 'fr-FR'); // "euro"
InternationalizationUtils.getCurrencyDisplayName('JPY', 'ja-JP'); // "日本円"
Gets the localized display name for a date/time field.
The field code (e.g., 'year', 'month', 'day', 'hour', 'minute')
The locale to use for formatting (default: user's locale)
Additional DisplayNames options for customization
The localized field display name
InternationalizationUtils.getDateTimeFieldDisplayName('year', 'en-US'); // "year"
InternationalizationUtils.getDateTimeFieldDisplayName('month', 'fr-FR'); // "mois"
InternationalizationUtils.getDateTimeFieldDisplayName('day', 'es-ES'); // "día"
Gets the localized display name for a language.
The language code (e.g., 'en', 'fr', 'es', 'zh')
The locale to use for formatting (default: user's locale)
Additional DisplayNames options for customization
The localized language display name
InternationalizationUtils.getLanguageDisplayName('en', 'en-US'); // "English"
InternationalizationUtils.getLanguageDisplayName('fr', 'fr-FR'); // "français"
InternationalizationUtils.getLanguageDisplayName('es', 'es-ES'); // "español"
Gets the localized display name for a region/country.
The region/country code (e.g., 'US', 'FR', 'JP', 'GB')
The locale to use for formatting (default: user's locale)
Additional DisplayNames options for customization
The localized region display name
InternationalizationUtils.getRegionDisplayName('US', 'en-US'); // "United States"
InternationalizationUtils.getRegionDisplayName('FR', 'fr-FR'); // "France"
InternationalizationUtils.getRegionDisplayName('JP', 'ja-JP'); // "日本"
Gets the localized display name for a writing script.
The script code (e.g., 'Latn', 'Cyrl', 'Arab', 'Hans')
The locale to use for formatting (default: user's locale)
Additional DisplayNames options for customization
The localized script display name
InternationalizationUtils.getScriptDisplayName('Latn', 'en-US'); // "Latin"
InternationalizationUtils.getScriptDisplayName('Cyrl', 'ru-RU'); // "кириллица"
InternationalizationUtils.getScriptDisplayName('Arab', 'ar-SA'); // "العربية"
Gets the display names of a unit
Unit code (e.g., 'meter', 'kilogram')
Locale to use (e.g., 'en-US', 'fr-FR')
DisplayNames options
Unit display name
getUnitDisplayName('meter', 'en-US') // 'meter'
getUnitDisplayName('kilogram', 'fr-FR') // 'kilogramme'
Formats a currency amount according to the specified locale and currency code.