Re: [Cppcms-users] Register textdomains at runtime
Brought to you by:
artyom-beilis
|
From: Artyom <art...@ya...> - 2010-08-30 04:24:53
|
> > Ok, in meantime I found the locale::generator::add_messages_domain() and > set_default_messages_domain(), but that raised a few more questions: > > - - Is it possible to remove a message domain again? (But only one and not > all message domains, so the clear_domains() method is not what I want) No, you can't. At least in current API. > - - Can I select the domain to use for basic_format::format or > locale::translate at method call somehow or do I have to call > set_default_messages_domain() on generator beforehand? Yes you can, read this: <http://cppcms.sourceforge.net/boost_locale/html/tutorial.html#6f4922f45568161a8cdf4ad2299f6d23> You need to use iostream manipulator booster::locale::as::domain("name") to switch domain in the stream. > If this is the > case, is this thread safe, so that I can change the > default_messages_domain even to different values for parallel requests? > It is not safe, actually access of any non-const member function of booster::locale::generator is not thread safe from multiple threads, see <http://cppcms.sourceforge.net/boost_locale/html/classboost_1_1locale_1_1generator.html> However, you can always create a separate instance of booster::locale::generator, create locale and install it using http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1context.html#9d6ee6ce1d9007ba1c0d7222fa022fd8 Please note, loading dictionaries and creating locale objects may be quite heavy operation, so use it very carefully. You may cache such custom locales withing your cppcms::application derived class that is cached in pool and not created frequently. Artyom |