Internationalization

The Mojo framework includes Mojo.Format, a set of locale-aware methods to assist you with formatting different types of text strings. The available methods are summarized in Table 11-2.

Table 11-2. Mojo.Locale and Mojo.Format methods

Method

Description

Mojo.Locale.getCurrentLocale()

Returns the currently set locale as an ISO 639-formatted string (e.g., en_us for US English)

Mojo.Locale.getCurrentFormatRegion()

Returns the currently set region as an ISO 639-formatted string (e.g., us for US English)

Mojo.Format.formatDate()

Formats the date object appropriately for the current locale

Mojo.Format.formatRelativeDate()

Formats the date object as with formatDate(), but returns yesterday/today/tomorrow if appropriate, or the day of the week if in the last week

Mojo.Format.formatNumber()

Converts a number to a string using the proper locale-based format for numbers and number separators

Mojo.Format.formatCurrency()

Converts a number representing an amount of currency to a string using the proper locale-based format for currency; does not do any currency rate conversion, just formatting

Mojo.Format.formatChoice()

Formats a choice list to handle things like replacement parameters with plurals

Mojo.Format.formatPercent()

Converts a number to a percent string using the proper locale-based format for percentages

Mojo.Format.using12HrTime()

Returns true if the current locale uses 12-hour time or false if 24-hour time

Mojo.Format.getCurrentTimeZone()

Returns current timezone

The behavior of some ...

Get Palm webOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.