N/format/i18n Module

Use the N/format/i18n module to format strings in international context and format numbers to currency or number strings. You can also use this module to format phone number to strings and parse strings to phone number.

                                   

In This Help Topic

N/format/i18n Module Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

format.CurrencyFormatter

Object

Client and server scripts

Represents the object that formats the number to currency string.

format.NumberFormatter

Object

Client and server scripts

Represents the object that formats the number to string.

format.PhoneNumberFormatter

Object

Client and server scripts

Represents the object that formats the phone number to string.

format.PhoneNumberParser

Object

Client and server scripts

Represents the object that parses the string to phone number.

Method

format.spellOut(options)

string

Client and server scripts

Creates a string containing the spelled-out version of the specified number in a specified locale.

format.getCurrencyFormatter(options)

object

Client and server scripts

Creates a format.CurrencyFormatter object to format numbers to currency strings.

format.getNumberFormatter(options)

object

Client and server scripts

Creates a format.NumberFormatter object to format numbers to strings.

format.getPhoneNumberFormatter(options)

object

Client and server scripts

Creates a format.PhoneNumberFormatter object to format phone numbers to strings.

format.getPhoneNumberParser(options)

object

Client and server scripts

Parses a phone number from a string. Returns a format.PhoneNumberParser object.

Enum

format.NegativeNumberFormat

enum

Client and server scripts

Holds the values for the negative number format.

format.Currency

enum

Client and server scripts

Holds the values for the currency code.

Currency Formatter Object Members

The following members are called on the format.CurrencyFormatter object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

CurrencyFormatter.currency

string

Client and server scripts

Indicates the currency code.

CurrencyFormatter.locale

string

Client and server scripts

The locale of the currency formatter.

CurrencyFormatter.symbol

string

Client and server scripts

Indicates the currency symbol.

CurrencyFormatter.numberFormatter

object

Client and server scripts

Contains the format.NumberFormatter object derived from format.CurrencyFormatter with the same number formatting parameters without currency symbol.

CurrencyFormatter.format(options)

string

Client and server scripts

Formats the number to the currency string.

Number Formatter Object Members

The following members are called on the format.NumberFormatter object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

NumberFormatter.groupSeparator

string

Client and server scripts

Indicates the group separator.

NumberFormatter.decimalSeparator

string

Client and server scripts

Indicates the decimal separator.

NumberFormatter.locale

string

Client and server scripts

The locale of the number formatter.

NumberFormatter.precision

number

Client and server scripts

Indicates the precision.

NumberFormatter.negativeNumberFormat

enum

Client and server scripts

Indicates the negative number format.

NumberFormatter.format(options)

string

Client and server scripts

Formats the number to string.

Phone Number Formatter Object Members

The following members are called on the format.PhoneNumberFormatter object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

format.PhoneNumberFormatter

Object

Client and server scripts

The object that formats the phone number to string.

Method

PhoneNumberFormatter.format(options)

string

Client and server scripts

Formats phone number object to string.

Enum

format.PhoneNumberFormatType

enum

Client and server scripts

Holds the values for the phone number format type.

format.Country

enum

Client and server scripts

Hold the values for the countries.

Phone Number Parser Object Members

The following members are called on the format.PhoneNumberParser object.

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Object

format.PhoneNumberParser

Object

Client and server scripts

The object that parses the string to phone number.

Method

PhoneNumberParser.parse(options)

Object of type PhoneNumber

Client and server scripts

Parses string to phone number.

Related Topics

General Notices