setLocale

Sets the country/language locale for CFML processing
and the page returned to the client. The locale value
determines the default format of date, time, number, and
currency values, according to language and regional
conventions.

setLocale(new_locale) → returns string

Argument Reference

new_locale string
Required

The name of a locale; for example, "English (US)"
Values:
  • Chinese (China)
  • Chinese (Hong Kong)
  • Chinese (Taiwan)
  • Dutch (Belgian)
  • Dutch (Standard)
  • English (Australian)
  • English (Canadian)
  • English (New Zealand)
  • English (US)
  • English (UK)
  • French (Belgian)
  • French (Canadian)
  • French (Standard)
  • French (Swiss)
  • German (Austrian)
  • German (Standard)
  • German (Swiss)
  • Italian (Standard)
  • Italian (Swiss)
  • Japanese
  • Korean
  • Norwegian (Bokmal)
  • Norwegian (Nynorsk)
  • Portuguese (Brazilian)
  • Portuguese (Standard)
  • Spanish (Modern)
  • Spanish (Standard)
  • Swedish

Examples
Sample code invoking the setLocale function

Outputs the current locale, Sets the locale to French (Belgian) and outputs it, then puts it back to the original and outputs it

<cfscript>
    currentLocale = getLocale();
    writeOutput("Current: ");
    writeDump(currentLocale);
    writeOutput("<br />");
    setLocale("French (Belgian)");
    writeOutput("New: ");
    writeDump(getLocale());
    writeOutput("<br />");
    setLocale(currentLocale);
    writeOutput("Original: ");
    writeDump(getLocale());
</cfscript>

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub