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 PropertyDescriptionSample Value
langLanguageen-US
dirDirection of textltr
localeLocaleen-CA
defaultCalendarDefault calendar format based on localeGregorian
defaultNumberingSystemDefault numbering system based on localelatn
calendarDataCalendar formats for the user’s localegregorian: {dayPeriods : {...}, days: {...}, eras: {...}, months: {...}, quarters: {...}}
currencyCurrency codeCAD
firstDayOfWeekFirst day of the week1
isEasternNameStyleSpecifies if a name follows Eastern style, for example, last name first name [middle] [suffix]false
common.calendarDataSupplementary 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.digitsUnicode characters for numerical values0123456789
dateTime.shortDateFormatShort style date formatMM/dd/yyyy
dateTime.mediumDateFormatMedium style date formatMMM d, yyyy
dateTime.longDateFormatLong style date formatMMMM d, yyyy
dateTime.shortDateTimeFormatShort style datetime formatMM/dd/yyyy h:mm a
dateTime.mediumDateTimeFormatMedium style datetime formatMMM d, yyyy h:mm:ss a
dateTime.longDateTimeFormatLong style datetime formatMMMM d, yyyy ‘at’ h:mm:ss a * z
dateTime.shortTimeFormatShort style time formath:mm a
dateTime.longTimeFormatLong style time formath:mmss a
number.currencyFormatCurrency format#, ##0.00
number.currencySymbolCurrency symbol$
number.decimalSeparatorDecimal separator.
number.exponentialSignExponential symbolE
number.groupingSeparatorGrouping separator,
number.infinityInfinity symbol
number.minusSignMinus sign symbol-
number.nanString for “Not a number”NaN
number.numberFormatNumber format#, ##0.###
number.perMilleSignPer mille symbol
number.percentFormatPercent format#, ###0%
number.percentSignPercent sign symbol%
number.plusSignPlus sign symbol+
number.superscriptExponentSignSuperscript exponent symbol×
showJapaneseCalendarSpecifies whether to show dates in the Japanese Imperial calendar formatfalse
timeZoneTime zoneAmerica/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