Access Internationalization Properties
Import internationalization properties from the @salesforce/i18n
scoped module. Lightning web components have internationalization properties that you can use to adapt your components for users worldwide, across languages, currencies, and timezones.
In a single currency organization, Salesforce administrators set the currency locale, default language, default locale, and default time zone for their organizations. Users can set their individual language, locale, and time zone on their personal settings pages.
Base Lightning components adapt automatically to the language, locale, and time zone settings of the Salesforce org they run in. To internationalize your components so that they also adapt, use the internationalization properties.
internationalizationPropertyName
—A name that refers to the internationalization property.internationalizationProperty
—An internationalization property.
The property values are returned for the current user.
Internationalization Property | Description | Sample Value |
---|---|---|
lang | Language | en-US |
dir | Direction of text | ltr |
locale | Locale | en-CA |
defaultCalendar | Default calendar format based on locale | Gregorian |
defaultNumberingSystem | Default numbering system based on locale | latn |
calendarData | Calendar formats for the user’s locale | gregorian: {dayPeriods : {...}, days: {...}, eras: {...}, months: {...}, quarters: {...}} |
currency | Currency code | CAD |
firstDayOfWeek | First day of the week | 1 |
isEasternNameStyle | Specifies if a name follows Eastern style, for example, last name first name [middle] [suffix] | false |
common.calendarData | Supplementary calendar data for common calendar formats. The value is determined by defaultCalendar . | gregorian:{calendarSystem:'solar',eras:{'0':{_end:'0-12-31'},'0':{_end:'1-01-01'}}} |
common.digits | Unicode characters for numerical values | 0123456789 |
dateTime.shortDateFormat | Short style date format | MM/dd/yyyy |
dateTime.mediumDateFormat | Medium style date format | MMM d, yyyy |
dateTime.longDateFormat | Long style date format | MMMM d, yyyy |
dateTime.shortDateTimeFormat | Short style datetime format | MM/dd/yyyy h:mm a |
dateTime.mediumDateTimeFormat | Medium style datetime format | MMM d, yyyy h:mm:ss a |
dateTime.longDateTimeFormat | Long style datetime format | MMMM d, yyyy ‘at’ h:mm:ss a * z |
dateTime.shortTimeFormat | Short style time format | h:mm a |
dateTime.longTimeFormat | Long style time format | h:mmss a |
number.currencyFormat | Currency format | #, ##0.00 |
number.currencySymbol | Currency symbol | $ |
number.decimalSeparator | Decimal separator | . |
number.exponentialSign | Exponential symbol | E |
number.groupingSeparator | Grouping separator | , |
number.infinity | Infinity symbol | ∞ |
number.minusSign | Minus sign symbol | - |
number.nan | String for “Not a number” | NaN |
number.numberFormat | Number format | #, ##0.### |
number.perMilleSign | Per mille symbol | ‰ |
number.percentFormat | Percent format | #, ###0% |
number.percentSign | Percent sign symbol | % |
number.plusSign | Plus sign symbol | + |
number.superscriptExponentSign | Superscript exponent symbol | × |
showJapaneseCalendar | Specifies whether to show dates in the Japanese Imperial calendar format | false |
timeZone | Time zone | America/Los_Angeles |
For LWR sites, the lang
and locale
are mapped to the language configured for the site, and timeZone
is determined by the browser’s timezone rather than the user’s personal settings.
Additionally, currency
, number.currencySymbol
, and number.currencyFormat
are unsupported.
If the site or org language configurations are updated, you must republish the site.
Values returned by an internationalization property correspond to the formatting described by the Unicode Locale Data Markup Language (LDML). For example, common.calendarData
follows the Calendar Data LDML specification.
Dates are formatted differently in different languages. For example, the US uses Month, Day, Year, like 2/15/19. The United Kingdom uses Day, Month, Year, like 15/2/19.
To format a date according to the user’s language, import the user’s locale from the @salesforce/i18n/locale
module. To format the date, use the JavaScript Internationalization API.
Alternatively, use the lightning-formatted-date-time
base component for date and time formatting.
This example uses the locale
and currency
properties to format a number into a localized currency string.
The Intl.NumberFormat
object defines the currency output. For a user's given locale, display the numerical value as currency and provide the localized currency symbol.
Alternatively, use the lightning-formatted-number
base component for number, currency, and percentage formatting.
To bind internationalization properties to HTML attributes, store them as private properties in your component's JavaScript file. Here, lang
determines the user's language and dir
specifies the direction that the text displays in HTML.
In your HTML template, reference the values with {property}
.
See Also
- Salesforce Help: Select Your Language, Locale, and Currency
- @salesforce Modules
- Unicode Locale Data Markup Language (LDML)