ColdFusion MX Coding Guidelines - Globalization

Globalization

Make sure your code takes account of the Globalization Standards listed on the Web Team Internationalization page.

If your source file is UTF-8 (which it should be - DWMX lets you create UTF-8 source files!), then you should include a page processing directive near the top of each and every source file:

<cfprocessingdirective pageEncoding="utf-8" />

All generated HTML must specify a Content-Type, a Content-Language and a character set encoding (which should be UTF-8). See also Accessibility / Section 508 Guidelines.

This will be in the Application.cfm file along with setEncoding() calls for form and URL scope:

<!--- Set encoding to UTF-8. --->
<cfset setEncoding("URL", "UTF-8") />
<cfset setEncoding("Form", "UTF-8") />
<!--- Set the output encoding to UTF-8 --->
<cfcontent type="text/html; charset=UTF-8" /> <!--- Set basic URL values into request scope ---> <cf_getrequestsettings /> <cfheader name="Content-Language" value="#request.language#" />

Any references to URL encoded data needs to use:

#URLEncodedFormat(myvar, "UTF-8")#

Note: the locale will be determined dynamically by code in Application.cfm from a combination of the URL (which will usually include a Macromedia 'region' code) and the query string (which may specify a loc parameter). The general outline of that logic, in pseudo-code would be:

if loc is present in query string 
then request.locale = loc value  
else if region is present in the URL 
then  request.locale = default locale for that region  
else  request.locale = "en_US"  endif

The language can be derived from the locale mechanically:

<cfset request.language = replace(request.locale,"_","-") />

A 'short locale' would also be needed for content queries - the first two letters of the specified or deduced locale:

<cfset request.loc2 = left(request.locale, 2) />

Here are some examples of the deduction we would do:

URL loc Region request
locale loc2 language
/products/index.cfm n/a n/a en_US en en-US
/products/index.cfm?loc=es es n/a es_ES es es-ES
/products/index.cfm?loc=es_US es_US n/a es_US es es-US
/la/products/index.cfm n/a la es_ES es es-ES
/la/products/index.cfm?loc=pt_BR pt_BR la pt_BR pt pt-BR

© 2010 Adobe Systems Incorporated. All rights reserved

Related Blog Entries

TweetBacks
Comments
timberland shoe company's Gravatar We are traveling by train. Out timberland hiking boots windows, we drink in the passing scene of cars on nearby highways, of children timberland shoe company waving at a crossing, of cattle grazing on a distant timberland boots hillside, of smoke pouring from a power plant, of row upon row of corn and wheat, of flatlands and timberland wheat shoes valleys, of mountains and rolling classic 3 eye timberland boat hillsides, of city skylines and village halls. But uppermost in our black timberland boots minds is the final destination.
# Posted By timberland shoe company | 28/08/10 10:25
BlogCFC was created by Raymond Camden. This blog is running version 5.9.5.005. Contact Blog Owner