Not yet rated

Problem

While displaying locale, we can use getLocale() function. But we may need to have output as localized version.

Solution

We can use GetLocaleDisplayName() function to display any locale in another locale.

Detailed explanation

Here is the sample code:

<cfscript>
       /* Defining custom parameters */
    myLocale = "tr";
    outputLocale = "de_DE";   
</cfscript>

<!--- Formatting output --->
<cfoutput>
    #GetLocaleDisplayName(myLocale, outputLocale)#<br>
</cfoutput>
<br />
<br />
<!--- Formatting output for available locales in ColdFusion --->

<cfoutput>
<cfloop index="loopid" list="#server.coldfusion.supportedlocales#">
    <!--- Rendering output in same locale --->
    #GetLocaleDisplayName(loopid, loopid)# <br />
</cfloop>

<!--- Formatting output for available locales in ColdFusion --->
<cfloop index="loopid" list="#server.coldfusion.supportedlocales#">
    <!--- Rendering any custom locale in other available locales --->   
    #GetLocaleDisplayName(myLocale, loopid)# <br />
</cfloop>
</cfoutput>


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes