Newer Version Available

This content describes an older version of this product. View Latest

$Locale

The $Locale global value provider gives you information about the browser's locale.
Attribute Description Sample Value
language Returns the language code. "en", "de", "zh"
country Returns the ISO 3166 representation of the country code. "US", "DE", "GB"
variant Returns the vendor and browser-specific code. "WIN", "MAC", "POSIX"
timezone Returns the time zone ID based on Java's java.util.TimeZone package. "EST", "PST", "GMT", "America/New_York"
numberformat Returns the number formatting based on Java's DecimalFormat class. "#,##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.

decimal Returns the decimal separator. "."
grouping Returns the grouping separator. ","
percentformat Returns the percent formatting. "#,##0%"
currencyformat Returns the currency formatting. "¤#,##0.00;(¤#,##0.00)"

¤ represents the currency sign, which is replaced by the currency symbol.

currency_code Returns the ISO 4217 representation of the currency code. "USD"
currency Returns the currency symbol. "$"

Example

This example shows how to get some $Locale attributes.

Component source

1swfobject.registerObject("clippy.codeblock-0", "9");<aura:component>
2    {!$Locale.language}
3    {!$Locale.timezone}
4    {!$Locale.numberFormat}
5    {!$Locale.currencyFormat}
6</aura:component>
7

The framework also provides localization support for input and output components.

Similarly, you can check locale information in a client-side controller using $A.get().
1({
2    checkDevice: function(component) {
3        var locale = $A.get("$Locale.language");
4        alert("You are using " + locale);
5    }
6})