Creates a new I18n instance for a specific locale
The locale to use for this I18n instance
Event emitter for missing translation notifications
The I18nManager instance containing translations and configuration
Translations for the selected locale Contains key-value pairs of translation identifiers and their messages
Translations for the fallback locale. The fallback translations are used when the selected locale translations are missing Contains key-value pairs of translation identifiers and their messages
The fallback locale for the current instance. Used when translations are missing in the primary locale
The locale for the formatter Used for all formatting operations
Format a numeric value for a given style
The numeric value to format (string, number, or bigint)
Optionaloptions: NumberFormatOptions
Optional formatting options (style, currency, etc.)
Formatted number string according to the current locale
Format a numeric value to a currency
The numeric value to format as currency
Currency formatting options including currency code
Formatted currency string
Format value as a date. The method accepts the following data types:
The date value to format
Optionaloptions: DateTimeFormatOptions
Optional date formatting options
Formatted date string according to the current locale
Format value as time. The method accepts the following data types:
The time value to format
Optionaloptions: TimeFormatOptions
Optional time formatting options
Formatted time string according to the current locale
Format value as relative diff between the current time and the given value. The following data types are allowed:
The date/time value to format relatively
The unit for relative formatting or 'auto' for automatic unit selection
Optionaloptions: RelativeTimeFormatOptions
Optional relative time formatting options
Formatted relative time string
Format the value to its plural counterpart using locale-specific plural rules
The numeric value to determine plural form for
Optionaloptions: PluralRulesOptions
Optional plural rules options
Plural category string ("zero", "one", "two", "few", "many", or "other")
Format an array of strings to a sentence using locale-appropriate conjunctions
Iterable of strings to format into a list
Optionaloptions: ListFormatOptions
Optional list formatting options (type, style)
Formatted list string
Format region, currency, language codes to their display names
The code to get display name for (language, region, currency, etc.)
Display names options specifying the type of code
Localized display name for the code
Creates a messages provider for VineJS validation framework
The prefix to use when looking up validation messages
A new I18nMessagesProvider instance
Returns the message for a given identifier
The translation identifier to resolve
Object with message and fallback status, or null if not found
Returns a boolean identifying if a fallback message for a given identifier exists or not
The translation identifier to check
True if the message exists in the fallback locale
Formats a message using the messages formatter
The translation identifier to format
Optionaldata: Record<string, any>
Optional data object for message interpolation
OptionalfallbackMessage: string
Optional fallback message when translation is missing
The formatted message string
Shorthand method for formatMessage - the primary translation method
The translation identifier to format
Optionaldata: Record<string, any>
Optional data object for message interpolation
OptionalfallbackMessage: string
Optional fallback message when translation is missing
The formatted message string
Formats a raw message string using the configured message formatter
The raw message string to format
Optionaldata: Record<string, any>
Optional data object for message interpolation
The formatted message string
I18n exposes the APIs to format values and translate messages for a given locale.
Under the hood it uses the I18nManager to load translations data
Example