IntlService

A service which provides internationalization methods and is bound to a specific locale.

NameTypeDefaultDescription

locale

string

The locale that will be used by the internationalization methods.

Constructors

IntlService

(locale: string)

Creates a new instance of the internationalization service.

Parameters

locale

string

The locale that will be used by the internationalization methods.

Methods

dateFieldName

Returns a localized date field name based on specific dateFieldName options.

Parameters

options

DateFieldNameOptions

The detailed configuration for the desired date field name.

Returns

string

  • The localized date field name from the current locale based on the option.

dateFormatNames

Returns the day names from the current locale based on the option.

Parameters

options

DateFormatNameOptions

The detailed configuration for the desired date format.

Returns

any

  • The day names from the current locale based on the option.

firstDay

Returns the first day index, starting from Sunday.

Returns

number

  • The index of the first day of the week (0 == Sunday).

format

Formats a string with placeholders such as Total amount {0:c}.

Parameters

format

string

The format string.

values

any[]

One or more values to output in the format string placeholders.

Returns

string

  • The formatted string.

formatDate

Converts a Date object to a string based on the specified format. If no format is provided, the default short date format is used.

Parameters

value

Date

The date which will be formatted.

format?

string | DateFormatOptions

The format string or options.

Returns

string

  • The formatted date.

formatNumber

Converts a Number to a string based on the specified format.

Parameters

value

number

The number which will be formatted.

format

string | NumberFormatOptions

The format string or options.

Returns

string

  • The formatted number.

numberSymbols

Returns the number symbols from the current locale.

Returns

any

  • The number symbols from the current locale.

parseDate

Converts a string to a Date object based on the specified format.

Parameters

value

string

The string which will be converted.

format?

string | string[] | DateFormatOptions | DateFormatOptions[]

The format strings or options.

Returns

Date

  • The parsed date.

parseNumber

Converts a string to a Number.

Parameters

value

string

The string which will be parsed.

format?

string | NumberFormatOptions

The format string or options.

Returns

number

  • The parsed number.

splitDateFormat

Splits the date format into objects which contain information about each part of the pattern.

Parameters

format

string | DateFormatOptions

The format string or options.

Returns

DateFormatPart[]

  • The date format parts.

toString

Converts an object to a string based on the specified format.

Parameters

value

any

The value which will be formatted.

format

any

The format to use.

Returns

string

  • The formatted object.