Newer Version Available
$Locale
The $Locale global value provider returns
information about the current user’s
preferred locale.
These attributes are based on Java’s Calendar, Locale and TimeZone classes.
| 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 | The vendor and browser-specific code. | "WIN", "MAC", "POSIX" |
Number and Date Formatting
The framework’s number and date formatting are based on Java’s DecimalFormat and DateFormat classes.
| 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" |
| 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%" |
| 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})