Skip to main content
Inspiring
November 15, 2008
Question

Get Locale country and language codes

  • November 15, 2008
  • 12 replies
  • 8389 views
I have checked the documentation, but nothing is jumping out at me. Is there a function that returns the locale country and language codes? GetLocale() returns the "locale name as it is represented in ColdFusion":

ie:
English (US)
Spanish (Standard)
...

What I am looking for is the ISO codes

en US
es ES
...

I can get the information using getPageContext(), but just wondered if I was overlooking a built-in CF function.
This topic has been closed for replies.

12 replies

Inspiring
November 28, 2008
-==cfSearching==- wrote:
> The flex examples look pretty good. Better than cfchart. I went the cfchart
> route because I know zero about flex ;-) Time to dig in and learn.

well we mostly build flex/cf apps these days, so yeah, i would recommend you
slurp down the flex kool-aid as fast as you can. the new real time collaboration
bits (cocomo) look like a sweet add-in for many of our GIS apps.

we often found that cfcharts were limiting (we do a *lot* of "science" based
apps) so for any serious server-side reporting, etc. we usually use jFreeChart
(it's annotation bits & box/whisker charts are especially nifty).

Inspiring
November 27, 2008
Sorry for the delayed response. I got majorly side-tracked with a bunch of other things.

> sorry, i meant is there "any chance of substituting a function"..for
> formatting a tooltip in webcharts3d.."like flex".

Other than a few "kludegy" ideas, the only way I could think of was to modify the jar. I decided not to as I did not know if / how that affected licensing.

The flex examples look pretty good. Better than cfchart. I went the cfchart route because I know zero about flex ;-) Time to dig in and learn.

Inspiring
November 21, 2008
-==cfSearching==- wrote:
> > any chance of substituting a function like flex?
>
> I am up for it, I just don't know much about flex. Any pointers?

sorry, i meant is there "any chance of substituting a function"..for formatting
a tooltip in webcharts3d.."like flex".

but if really wanted you could redo it in flex:

for free
http://dougmccune.com/blog/2007/02/01/building-a-gantt-chart-component-in-flex/
http://flexgeek.wordpress.com/2007/06/13/simple-ganttchart-using-advanceddatagrid-of-flex-30-moxie/

or pay $800 US
http://www.ilog.com/products/ilogelixir/

since you've got cf on the backend it would be fairly easy to use it as your
locale resource provider & pass back the localized bits to the flex gantt
"widget". pretty much all the flex UI components have options to use a function
for labels, tooltips, etc. fairly well thought out :-)
Inspiring
November 20, 2008
> i don't see anything to set locales for tooltips (are these popups??).
> any chance of substituting a function like flex?

Neither do I. Yes, if you view source they are just html that displays on mouseover. The values are formatted as en_US, so clearly webcharts is forgetting to take locale into account when it generates them.

> any chance of substituting a function like flex?

I am up for it, I just don't know much about flex. Any pointers?
Inspiring
November 20, 2008
> i don't see anything to set locales for tooltips (are these popups??).
> any chance of substituting a function like flex?

Neither do I. Yes, if you view source they are just html that displays on mouseover. The values are formatted as en_US, so clearly webcharts is forgetting to take locale into account when it generates them.

> any chance of substituting a function like flex?

I am up for it, I just don't know much about flex. Any pointers?
Inspiring
November 19, 2008
Inspiring
November 19, 2008
-==cfSearching==- wrote:
> If I do not set/change the Locale explicitly, it uses the server default from what I can tell. (ie en_US)

probably a dumb question, then why bother finding the server locale & setting it
"again"?

Inspiring
November 19, 2008
PaulH wrote:
> probably a dumb question

Not a dumb question. There are few things going on.

Short story, I needed to customize the display of dates in a gantt chart on-the-fly. Webcharts uses the server locale by default. To change it, you pass in the desired locale information via xml. That xml is fed into the charting component and used to generate the final chart (That is why I needed the iso codes). That part works fine.

(ie
<locale lang="es" country="ES" variant=""/>
)

> , then why bother finding the server locale > & setting it "again"?


Since the webcharts documentation is a bit sparse on the topic of localization, I temporarily changed the locale to better understand its behavior and debug another issue. The issue relates to tool tips. For whatever reason, webcharts correctly formats the chart labels with whatever locale I select. But ... when I try and format dates inside a tool tip, webcharts always uses the default locale for formatting.

For example if I my xml contains:

<locale lang="es" country="ES" variant=""/>

The results are:
Chart labels display (spanish):: *** lunes, martes, miercoles, jueves, ...
Tool tips display (english):: *** monday, tuesday, wednesday, thursday, ...

You get the same results using the webcharts utility. The results are obviously wrong, so I am wondering if I stupidly overlooked a property or something ..
Inspiring
November 19, 2008
> i see. what happens if you don't set a locale? does it use
> the server default anyway?

If I do not set/change the Locale explicitly, it uses the server default from what I can tell. (ie en_US)
Inspiring
November 19, 2008
> I needed to create a customizable chart with webcharts. To set
> the locale, its model requires the iso codes.

... So inside my function, I needed to determine the current locale if one was not specified.
Inspiring
November 19, 2008
-==cfSearching==- wrote:
> Weird. But thanks for the "heads up". I will use the java default instead.

what are you trying to do anyway?
Inspiring
November 19, 2008
> what are you trying to do anyway?

I needed to create a customizable chart with webcharts. To set the locale, its model requires the iso codes.