ClientLocale()
Last updated April 23, 2002
Version: 1 | Requires: CF5 | Library: UtilityLib
Description:
This function uses the CGI variable HTTP_ACCEPT_LANGUAGE to attempt to choose an appropriate locale for the visitor. You could then use this locale when displaying dates, numbers, etc. or handling data entered by the visitor.
Return Values:
Returns a string.
Example:
Your locale seems to be: <cfoutput>#ClientLocale()#</cfoutput>
Parameters:
No arguments.
Full UDF Source:
/**
* Attempts to deduce the visitor's locale.
*
* @return Returns a string.
* @author Matthew Walker (matthew@cabbagetree.co.nz)
* @version 1, April 23, 2002
*/
function ClientLocale() {
var FirstLocale = SpanExcluding(CGI.HTTP_ACCEPT_LANGUAGE, ",;");
var LanguageCode = ListFirst(FirstLocale, "-");
var CountryCode = "";
if ( ListLen(FirstLocale, "-") EQ 2 )
CountryCode = ListGetAt(FirstLocale, 2, "-");
switch(LanguageCode){
case "nl":
switch(CountryCode){
case "be":
return "Dutch (Belgian)";
default:
return "Dutch (Standard)";
}
case "en":
switch(CountryCode){
case "au":
return "English (Australian)";
case "ca":
return "English (Canadian)";
case "nz":
return "English (New Zealand)";
case "gb":
return "English (UK)";
case "us":
return "English (US)";
default:
return "English (UK)";
}
case "fr":
switch(CountryCode){
case "be":
return "French (Belgian)";
case "ca":
return "French (Canadian)";
case "ch":
return "French (Swiss)";
default:
return "French (Standard)";
}
case "de":
switch(CountryCode){
case "at":
return "German (Austrian)";
case "ch":
return "German (Swiss)";
default:
return "German (Standard)";
}
case "it":
switch(CountryCode){
case "ch":
return "Italian (Swiss)";
default:
return "Italian (Standard)";
}
case "nb":
return "Norwegian (Bokmal)";
case "nn":
return "Norwegian (Nynorsk)";
case "pt":
switch(CountryCode){
case "br":
return "Portuguese (Brazilian)";
default:
return "Portuguese (Standard)";
}
case "es":
switch(CountryCode){
case "mx":
return "Spanish (Mexican)";
default:
return "Spanish (Modern)";
}
default:
return GetLocale();
}
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016