home Links Articles Books Past Meetings Photos SiteMap
The MDCFUG is sponsored by TeraTech. Visit us at www.TeraTech.com

Please send
comments/questions to



ColdFusion MX Coding Guidelines - Globalization

Release 3.0.2 (10/17/2003)

« Database Conventions | Contents | Appendix: Performance Techniques »


Make sure your code takes account of the Globalization Standards listed on the Internationalization Macronet 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.

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
    request.locale = "en_US"

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

« Database Conventions | Contents | Appendix: Performance Techniques »

No comments found

Source: http://livedocs.macromedia.com/wtg/public/coding_standards/globalization.html

Home | Links | Articles | Past Meetings | Meeting Photos | Site Map
About MDCFUG | Join | Mailing List |Forums | Directions |Suggestions | Quotes | Newbie Tips

Copyright © 1997-2017, Maryland Cold Fusion User Group. All rights reserved.
< >