View comments | RSS feed

Locales

A locale identifies the exact language and cultural settings to use for a user. The locale controls how to format the following:

ColdFusion MX supports all locales supported by the JVM that it uses.

Note: Current JVM versions (through 1.4.2) do not support localized numbers such as Arabic-hindic numbers used in Arabic locales or hindic digits used in Hindi locales. ColdFusion uses Arabic numbers in all locales.

Locale names

ColdFusion MX 7 supports two formats for specifying locale names: the standard Java locale names and the ColdFusion naming convention that was required through ColdFusion MX 6.1.

The Server.coldfusion.supportedlocales variable is a comma-delimited list of the locale names that you can specify.

ColdFusion also includes a GetLocaleDisplayName function that returns a locale name in a format that is meaningful to users. It lets you display the locale using words in the user's language; for example, français (France).

Determining the locale

ColdFusion MX 7 determines the locale value as follows:

Using the locale

The SetLocale function determines the default formats that ColdFusion uses to output date, time, number, and currency values. You use the GetLocale function to determine the current locale setting of ColdFusion, or you can use the GetLocaleDisplayName function to get the locale name in a format that is meaningful to users. If you have not made a call to SetLocale, GetLocale returns the locale of the JVM.

The current locale has two effects:

Note: In earlier versions of ColdFusion, the default locale was always English, not the operating system's locale. For the Japanese version of ColdFusion, the default was Japanese.

The following example uses the LSCurrencyFormat function to output the value 100,000 in monetary units for all the ColdFusion-supported locales. You can run this code to see how the locale affects the data returned to a browser.

<p>LSCurrencyFormat returns a currency value using the locale convention. 
<!--- loop through list of locales; show currency values for 100,000 units --->
<cfloop LIST = "#Server.Coldfusion.SupportedLocales#"
index = "locale" delimiters = ","> <cfset oldlocale = SetLocale(locale)> <cfoutput><p><b><I>#locale#</I></b><br> Local: #LSCurrencyFormat(100000, "local")#<br> International: #LSCurrencyFormat(100000, "international")#<br> None: #LSCurrencyFormat(100000, "none")#<br> <hr noshade> </cfoutput> </cfloop>

This example uses the ColdFusion variable Server.Coldfusion.SupportedLocales, which contains a list of all supported ColdFusion locales.


ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


PaulH said on Feb 28, 2005 at 3:00 AM :
"Note: Current JVM versions (through 1.4.2) do not support localized numbers such as Arabic-hindic numbers used in Arabic locales or hindic digits used in Hindi locales. ColdFusion uses Arabic numbers in all locales."

not quite. first off it's "Arabic-Indic" digits. next that sentence suggests cf doesn't support any localized digits where it's mainly just the arabic locales that aren't supported. i'm unsure of the term "hindic" as used here but in any case cf actually does format localized digits in hindu locale (hi_IN): रू १००,०००.००. finally not sure if the term "Arabic numbers" is appropriate here, "european digits/numbers" is probably cleaer.
ASandstrom said on Aug 15, 2005 at 8:26 AM :
In Java, (icu4j 3.4) the acceptLanguage method, which helps to figure out a good locale to use when presented with a list of languages from HTTP_ACCEPT_LANGUAGE,. works as expected.. In ColdFusion , if you don't init the array, ColdFusion throws "java.lang.ArrayIndexOutOfBoundsException: 0".

The problem is that the array you are passing has no elements in it. However, if you do the following,

fallback=arrayNew(1);
fallback[1] = true;

the Java array that is created will have a length of 1.

Here is the code used to create the array:

int size = input.size();
Class compType = target.getComponentType();
Object retval = java.lang.reflect.Array.newInstance(compType, size);
// init the array values...

Once you do this, it should work OK.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00001202.htm