Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
$Locale
| Attribute | Description | Sample Value |
|---|---|---|
| country | The ISO 3166 representation of the country code based on the language locale. | "US", "DE", "GB" |
| currency | The currency symbol. | "$" |
| currencyCode | The ISO 4217 representation of the currency code. | "USD" |
| decimal | The decimal separator. | "." |
| firstDayOfWeek | The first day of the week, where 1 is Sunday. | 1 |
| grouping | The grouping separator. | "," |
| isEasternNameStyle | Specifies if a name is based on eastern style, for example, last name first name [middle] [suffix]. | false |
| labelForToday | The label for the Today link on the date picker. | “Today” |
| language | The language code based on the language locale. | "en", "de", "zh" |
| langLocale | The locale ID. | “en_US”, “en_GB” |
| nameOfMonths | The full and short names of the calendar months | { fullName: “January”, shortName: “Jan” } |
| nameOfWeekdays | The full and short names of the calendar weeks | { fullName: “Sunday”, shortName: “SUN” } |
| timezone | The time zone ID. | "America/Los_Angeles" |
| userLocaleCountry | The country based on the current user’s locale | “US” |
| userLocaleLang | The language based on the current user’s locale | “en” |
| variant | Deprecated. The variation for a language dialect. |
Number and Date Formatting
| Attribute | Description | Sample Value |
|---|---|---|
| currencyFormat | The currency format. | "¤#,##0.00;(¤#,##0.00)" ¤ represents the currency sign, which is replaced by the currency symbol. |
| dateFormat | The date format. | "MMM d, yyyy" |
| datetimeFormat | The date time format. | "MMM d, yyyy h:mm:ss a" |
| longDateFormat | The long date format. | "MMMM d, yyyy" |
| numberFormat | The number format. | "#,##0.###" # represents a digit, the comma is a placeholder for the grouping separator, and the period is a placeholder for the decimal separator. Zero (0) replaces # to represent trailing zeros. |
| percentFormat | The percentage format. | "#,##0%" |
| shortDateFormat | The short date format. | "M/d/yyyy" |
| shortDatetimeFormat | The short date time format. | "M/d/yyyy h:mm a" |
| shortTimeFormat | The short time format. | "h:mm a" |
| showJapaneseCalendar | Specifies whether to show dates in the Japanese Imperial calendar format | false |
| timeFormat | The time format. | "h:mm:ss a" |
| zero | The character for the zero digit. | “0” |
Example
This example shows how to retrieve different $Locale attributes.
Component source
1<aura:component>
2 {!$Locale.language}
3 {!$Locale.timezone}
4 {!$Locale.numberFormat}
5 {!$Locale.currencyFormat}
6</aura:component>1({
2 checkDevice: function(component) {
3 var locale = $A.get("$Locale.language");
4 alert("You are using " + locale);
5 }
6})