Boost logo

Boost :

Subject: Re: [boost] [Locale] Static locale initialisation
From: Artyom (artyomtnk_at_[hidden])
Date: 2010-04-11 15:25:53


>
> Now that *that* part (not crashing) is fixed, I'm running
> into another
> problem. I can see the .mo file being loaded;
> excellent! But when I try
> to translate a string, the translation mechanism fails to
> find it! This
> only happens when i set the locale statically. If I
> set it just before
> using translate() it works fine.
>
> Here is the repro code: http://www.doc.ic.ac.uk/~awl03/locale_test2.zip
>
> To see the different situations, change which commentted
> line declaring
> LocaleSetup.

Ok, you are right, I managed to reproduce it. Looks like something
overerites the created locale with other one.

Maybe standard library defines global locale after it is defined in
the constructor and this is just a question of an order of
operation. I don't know I'll try to figure out.

Note: I've tested on Linux and Windows with GCC with both static
and dynamic libraries, this works. Looks like it happens only with MSVC.

In any case... I don't think that defining the global locale in static
constructor is generally good idea.

For unit test you may use the trick I described with testing if
the current locale has boost::locale::info facet.

Best,
  Artyom

      


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk