Interface Globalization

This plugin obtains information and performs operations specific to the user's locale and timezone.

Index

Methods

Methods

public dateToString(date: Date, onSuccess: (date: { value: string; }) => void, onError: (error: GlobalizationError) => void, options?: { type?: string; item?: string; })

Returns a date formatted as a string according to the client's locale and timezone.

Parameters

  • date: Date

    Date to format.

  • onSuccess: (date: { value: string; }) => void

    Called on success with a properties object, that should have a value property with a String value.

  • onError: (error: GlobalizationError) => void

    Called on error with a GlobalizationError object. The error's expected code is GlobalizationError.FORMATTING_ERROR.

  • options?: { type?: string; item?: string; } optional

    Optional format parameters. Default {formatLength:'short', selector:'date and time'}

public getCurrencyPattern(currencyCode: string, onSuccess: (result: GlobalizationCurrencyPattern) => void, onError: (error: GlobalizationError) => void)

Returns a pattern string to format and parse currency values according to the client's user preferences and ISO 4217 currency code.

Parameters

  • currencyCode: string

    Should be a String of one of the ISO 4217 currency codes, for example 'USD'.

  • onSuccess: (result: GlobalizationCurrencyPattern) => void

    Called on success getting pattern with a GlobalizatioCurrencyPattern object

  • onError: (error: GlobalizationError) => void

    Called on error getting pattern with a GlobalizationError object. The error's expected code is GlobalizationError.FORMATTING_ERROR.

public getDateNames(onSuccess: (names: { value: string[]; }) => void, onError: (error: GlobalizationError) => void, options?: { type?: string; item?: string; })

Returns an array of the names of the months or days of the week, depending on the client's user preferences and calendar.

Parameters

  • onSuccess: (names: { value: string[]; }) => void

    Called on success getting names with a properties object, that should have a value property with a String[] value.

  • onError: (error: GlobalizationError) => void

    Called on error getting the language with a GlobalizationError object. The error's expected code is GlobalizationError.UNKNOWN_ERROR.

  • options?: { type?: string; item?: string; } optional

    Optional parameters. Default: {type:'wide', item:'months'}

public getDatePattern(onSuccess: (datePattern: GlobalizationDatePattern) => void, onError: (error: GlobalizationError) => void, options?: { type?: string; item?: string; })

Returns a pattern string to format and parse dates according to the client's user preferences.

Parameters

  • onSuccess: (datePattern: GlobalizationDatePattern) => void

    Called on success getting pattern with a GlobalizationDatePattern object

  • onError: (error: GlobalizationError) => void

    Called on error getting pattern with a GlobalizationError object. The error's expected code is GlobalizationError.PATTERN_ERROR.

  • options?: { type?: string; item?: string; } optional

    Optional format parameters. Default {formatLength:'short', selector:'date and time'}

public getFirstDayOfWeek(onSuccess: (day: { value: number; }) => void, onError: (error: GlobalizationError) => void)

Returns the first day of the week according to the client's user preferences and calendar.

Parameters

  • onSuccess: (day: { value: number; }) => void

    Called on success with a day object, that should have a value property with a number value.

  • onError: (error: GlobalizationError) => void

    Called on error with a GlobalizationError object. The error's expected code is GlobalizationError.UNKNOWN_ERROR.

public getLocaleName(onSuccess: (locale: { value: string; }) => void, onError: (error: GlobalizationError) => void)

Get the string identifier for the client's current locale setting.

Parameters

  • onSuccess: (locale: { value: string; }) => void

    Called on success getting the locale identifier with a properties object, that should have a value property with a String value.

  • onError: (error: GlobalizationError) => void

    Called on error getting the locale identifier with a GlobalizationError object. The error's expected code is GlobalizationError.UNKNOWN_ERROR.

public getNumberPattern(onSuccess: (result: GlobalizationNumberPattern) => void, onError: (error: GlobalizationError) => void, format?: { type?: string; })

Returns a pattern string to format and parse numbers according to the client's user preferences.

Parameters

  • onSuccess: (result: GlobalizationNumberPattern) => void

    Called on success getting pattern with a GlobalizationNumberPattern object

  • onError: (error: GlobalizationError) => void

    Called on error getting the language with a GlobalizationError object. The error's expected code is GlobalizationError.PATTERN_ERROR.

  • format?: { type?: string; } optional

public getPreferredLanguage(onSuccess: (language: { value: string; }) => void, onError: (error: GlobalizationError) => void)

Get the string identifier for the client's current language.

Parameters

  • onSuccess: (language: { value: string; }) => void

    Called on success getting the language with a properties object, that should have a value property with a String value.

  • onError: (error: GlobalizationError) => void

    Called on error getting the language with a GlobalizationError object. The error's expected code is GlobalizationError.UNKNOWN_ERROR.

public isDaylightSavingsTime(date: Date, onSuccess: (result: { dst: boolean; }) => void, onError: (error: GlobalizationError) => void)

Indicates whether daylight savings time is in effect for a given date using the client's time zone and calendar.

Parameters

  • date: Date

    Date to check

  • onSuccess: (result: { dst: boolean; }) => void

    Called on success with a properties object, that should have a dst property with a boolean value.

  • onError: (error: GlobalizationError) => void

    Called on error with a GlobalizationError object. The error's expected code is GlobalizationError.UNKNOWN_ERROR.

public nubmerToString(value: number, onSuccess: (result: { value: string; }) => void, onError: (error: GlobalizationError) => void, format?: { type?: string; })

Returns a number formatted as a string according to the client's user preferences.

Parameters

  • value: number

    Number to format

  • onSuccess: (result: { value: string; }) => void

    Called on success with a result object, that should have a value property with a String value.

  • onError: (error: GlobalizationError) => void

    Called on error with a GlobalizationError object. The error's expected code is GlobalizationError.FORMATTING_ERROR.

  • format?: { type?: string; } optional

    Optional format parameters. Default: {type:'decimal'}

public stringToDate(dateString: string, onSuccess: (date: GlobalizationDate) => void, onError: (error: GlobalizationError) => void, options?: { type?: string; item?: string; })

Parses a date formatted as a string, according to the client's user preferences and calendar using the time zone of the client, and returns the corresponding date object.

Parameters

  • dateString: string

    String to parse

  • onSuccess: (date: GlobalizationDate) => void

    Called on success with GlobalizationDate object

  • onError: (error: GlobalizationError) => void

    Called on error getting the language with a GlobalizationError object. The error's expected code is GlobalizationError.PARSING_ERROR.

  • options?: { type?: string; item?: string; } optional

    Optional parse parameters. Default {formatLength:'short', selector:'date and time'}

public stringToNumber(value: string, onSuccess: (result: { value: number; }) => void, onError: (error: GlobalizationError) => void, format?: { type?: string; })

Parses a number formatted as a string according to the client's user preferences and returns the corresponding number.

Parameters

  • value: string

    String to parse

  • onSuccess: (result: { value: number; }) => void

    Called on success with a result object, that should have a value property with a number value.

  • onError: (error: GlobalizationError) => void

    Called on error with a GlobalizationError object. The error's expected code is GlobalizationError.FORMATTING_ERROR.

  • format?: { type?: string; } optional

    Optional format parameters. Default: {type:'decimal'}