[fxruby-users] FXApp & Time localization
lyle at lylejohnson.name
Wed Dec 5 10:43:57 EST 2007
On 12/4/07, Philippe Lang <philippe.lang at attiksystem.ch> wrote:
> After FXApp is instanciated, the Time class is suddenly being localized,
> and this breaks a few things elsewhere is my program.
> Can anyone tell me me what happens here? Is there a workaround?
You are correct that when the FXApp instance is initialized, it calls
the setlocale() function (from the C library) to set the locale to the
native environment (presumably, "fr-FR" in your case).
Then Ruby's Time class uses the strftime() function from the C library
to provide the stringified version of the time, and strftime() uses
the current locale in that process. So that's why you're getting
localized day and month names.
I know that you've already found a workaround, using the DateTime
class instead of the Time class, but I *think* another workaround
would be to set the LC_ALL environment variable to "en_US" (or some
other English-language locale). Then, when FOX calls setlocale(), it
would pick up this value instead of the default "fr_FR" value that
it's currently getting.
Hope this helps,
More information about the fxruby-users