[haiku-commits] Re: haiku: hrev43781 - src/bin/locale src/system/libroot/add-ons/icu headers/private/libroot/locale data/etc src/preferences/time

  • From: Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 24 Feb 2012 11:07:58 +0100

Hi Axel,

On 2012-02-24 at 10:42:02 [+0100], Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> 
wrote:
> On 23.02.2012 23:28, zooey@xxxxxxxxxxxxxxx wrote:
> > +    setlocale(LC_ALL, "");
> 
> Why exactly is this needed, what does it change?

As I said in the commit message: Both Time and Deskbar use BCalendarView, 
which uses BDateTime, which invokes strftime() to access names of days and 
months. Unless setlocale() is invoked, only the POSIX locale will ever be 
active, so strftime() will always yield the English names. In order to 
localize the calendar view, strftime() has to produce the localized names, 
though, thus the invocation of setlocale(LC_ALL, ""), which will initialize 
the locale structures to match what's defined by the LC_... environment 
variables.

That of course activates localization for the whole team, which in case of 
Deskbar has the side-effect of switching all the add-ons into localized 
mode, too. As a result, ProcessController is now using German number 
formatting for me on the 'Memory usage' page. I'm not quite sure all 
add-ons will like that, though, as some may not deal properly with the 
changed results of printf(), scanf() and friends. We'll see, I suppose ...

An alternative would be to adjust BDateTime to use the LocaleKit instead of 
the POSIX localization API, but that would require merging liblocale.so 
into libbe.so first (and then actually implementing the required 
functionality!).

cheers,
        Oliver

Other related posts: