Newer Version Available
$Locale
The $Locale global value provider returns
information about the browser's locale.
These attributes are based on Java’s Locale and TimeZone classes.
| Attribute | Description | Sample Value |
|---|---|---|
| country | The ISO 3166 representation of the country code. | "US", "DE", "GB" |
| currency | The currency symbol. | "$" |
| currencyCode | The ISO 4217 representation of the currency code. | "USD" |
| decimal | The decimal separator. | "." |
| grouping | The grouping separator. | "," |
| language | The language code. | "en", "de", "zh" |
| langLocale | The locale ID. | “en_US”, “en_GB” |
| timezone | The time zone ID. | "America/Los_Angeles", "America/New_York" |
| 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" |
Example
This example shows how to retrieve different $Locale attributes.
Component source
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<aura:component>
18 {!$Locale.language}
19 {!$Locale.timezone}
20 {!$Locale.numberFormat}
21 {!$Locale.currencyFormat}
22</aura:component>
231({
2 checkDevice: function(component) {
3 var locale = $A.get("$Locale.language");
4 alert("You are using " + locale);
5 }
6})