Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SetLocale no effect in event gateway

Guest
Aug 04, 2008 Aug 04, 2008
SetLocale() is ignored when a CFC is called through an event gateway. SetLocale() works fine when called through an ordinary HTTP request. When called through the gateway the locale is always set as default locale that the server JVM instance was installed with.

Does anybody have a workaround for this?
We use MX7.

Here is some example code if you want to test:
<cfset message = StructNew()>
<cfset message.method = "onTest">
<cfset pushQueue = SendGatewayMessage("LocaleTest",message)>

Create a gateway "LocaleTest" pointing to "LocaleText.cfc" which looks like this:
<cfcomponent>

<cffunction name="onTest" output="no">
<cfargument name="CFEvent" type="struct" required="yes">

<!--- choose a different locale then your server default --->
<cfset SetLocale("en_GB")>
<cffile action="append" file="c:\temp.log" output="#GetLocale()#">

</cffunction>

</cfcomponent>

You can find the output in c:{temp.log, you will see it doesnt take the locale set by SetLocale()
TOPICS
Event gateways
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 05, 2008 Aug 05, 2008
Leo_CF wrote:
> SetLocale() is ignored when a CFC is called through an event gateway.
> SetLocale() works fine when called through an ordinary HTTP request. When
> called through the gateway the locale is always set as default locale that the
> server JVM instance was installed with.

ok, i can confirm for asynch gateways.

> Does anybody have a workaround for this?

not sure i'd class this as a "workaround" as it's pretty drastic & i have not
tested for any side effects but this "works":

<...
Translate
LEGEND ,
Aug 05, 2008 Aug 05, 2008
Leo_CF wrote:
> SetLocale() is ignored when a CFC is called through an event gateway.
> SetLocale() works fine when called through an ordinary HTTP request. When
> called through the gateway the locale is always set as default locale that the
> server JVM instance was installed with.

what kind of gateway?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 05, 2008 Aug 05, 2008
Leo_CF wrote:
> SetLocale() is ignored when a CFC is called through an event gateway.
> SetLocale() works fine when called through an ordinary HTTP request. When
> called through the gateway the locale is always set as default locale that the
> server JVM instance was installed with.

ok, i can confirm for asynch gateways.

> Does anybody have a workaround for this?

not sure i'd class this as a "workaround" as it's pretty drastic & i have not
tested for any side effects but this "works":

<cfscript>
locale=createObject("java","java.util.Locale");
thisLocale=locale.init("th","TH");
originalLocale=locale.getDefault();
locale.setDefault(thisLocale);
</cfscript>

<!--- note that cflog doesn't do unicode --->
<cflog text="#getLocale()# ::: #LSdateFormat(now(),'FULL')#" file="localeTest">

<cfscript>
// return to original locale
locale.setDefault(originalLocale);
</cfscript>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 06, 2008 Aug 06, 2008
Thanks Paul, that works! I will do some extra testing to look for any side-effects
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 06, 2008 Aug 06, 2008
LATEST
the cf team's been made aware of this & they've found the problem already. i don't have a timeline but it *will* get fixed.


btw don't forget to var scope that locale stuff.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources