Re: setlocale() evil?

On Wed, 2003-06-25 at 09:31, Bill Haneman wrote:
> Hi:
> I see nobody has replied.  I don't think we should touch this until we
> have a clearer explanation of the problems.
> Dom Lachowicz didn't elaborate on the issues (other than pointing out
> that setlocale() isn't thread-safe, which I think most of us knew
> already).
> Some applications really do need a way to alter the message catalogs
> they use (and formatting conventions for currency, decimal points, etc.)
> on-the-fly.  For instance it happens with assistive technologies if for
> instance annotations need to be provided to the user in a
> locale/language appropriate to the application's locale as opposed to
> the default locale of the assistive technology (since assistive
> technologies are "meta-apps").  Maybe that's confusing, here's an
> example:
> screen reader is describing a button, it gets localized UTF-8 from the
> application which contains the button's label, and also it gets
> information about the label's accelerators.  The screenreader is running
> in locale "DE_ch" (or is it CH_de? I forget), the application is running
> in "FR_ch" (the speaker is bilingual).  So the screenreader reads the
> French label - and the user wants the word "accelerator" to be
> translated to FR and not DE.  Other cases frequently turn up - mostly in
> the case where different apps are either running in different locales,
> or, perhaps more commonly, when applications are incompletely localized
> and the bilingual user wants to run them anyhow.
> Anyway, setlocale() seems to be the only workable way to accomplish this
> today (in conjunction with information about an application's current
> locale or LANG setting, which can be gotten from the _WM_ properties). 
> It's an important use case for screenreader developers.

There's nothing wrong with setlocale() in an application that knows
it isn't threaded. What was being pointed out in the bug report was
that libgnomeprint was doing it in a library which can't know the
app isn't threaded.

In a threaded app, if you actually needed to switch locales, you would
need to use something like recent GNU libc's uselocale(). Luckily,
in most cases, there are other alternatives, as described in the
bug report.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]