Sets a country/language locale option for a ColdFusion application user; the setting persists for the current ColdFusion application session. The locale value encapsulates a set of attributes that determine the default display format of date, time, number, and currency values, according to language and regional conventions.
For information about determining the locale value, see "GetLocale".
An element from the list of locales that ColdFusion supports, as a string.
International functions, System functions
SetLocale(new_locale)
Parameter | Description |
---|---|
new_locale |
The name of a locale; for example, "en_US" (English, United States) |
This function uses Java standard locale formatting rules on all platforms.
A locale value can be explicitly set in the following ways:
response.setLocale ( new Locale( "de", "DE") )
SetLocale ("German (Standard)"
The locale value persistence and usage hierarchy is as follows:
ColdFusion supports the following locale options. You can use either the ColdFusion locale name or the Java standard locale string.
Note: ColdFusion uses the Spanish (Standard) formats for Spanish (Modern) and Spanish (Standard).
This function can restore a locale setting by referencing the session variable that stores a locale, as follows:
<cfset oldlocale = SetLocale("localename")>
Note: The variable server.ColdFusion.SupportedLocales
is initialized at startup with a comma-delimited list of the locales that ColdFusion and the operating system support. If it is called with a locale that is not in the list, SetLocale
fails.
<h3>SetLocale Example</h3> <p>SetLocale sets the locale to the specified new locale for the current session. <p>A locale encapsulates the set of attributes that govern the display and formatting of date, time, number, and currency values. <p>The locale for this system is <cfoutput>#GetLocale()#</cfoutput> <p><cfoutput><I>the old locale was #SetLocale("English (UK)")#</I> <p>The locale is now #GetLocale()#</cfoutput>