diff --git a/boost/locale/gnu_gettext.hpp b/boost/locale/gnu_gettext.hpp index b739cbb..b9bf07e 100644 --- a/boost/locale/gnu_gettext.hpp +++ b/boost/locale/gnu_gettext.hpp @@ -231,6 +231,31 @@ namespace gnu_gettext { template message_format *create_messages_facet(catalog_info const &info); + /// + /// Gets catalog information from a locale. + /// + template + catalog_info get_catalog_info(std::locale const& loc); + + /// \cond INTERNAL + + template<> + BOOST_LOCALE_DECL catalog_info get_catalog_info(std::locale const& loc); + + template<> + BOOST_LOCALE_DECL catalog_info get_catalog_info(std::locale const& loc); + + #ifdef BOOST_HAS_CHAR16_T + template<> + BOOST_LOCALE_DECL catalog_info get_catalog_info(std::locale const& loc); + #endif + + #ifdef BOOST_HAS_CHAR32_T + template<> + BOOST_LOCALE_DECL catalog_info get_catalog_info(std::locale const& loc); + #endif + + /// \endcond // ---- deprecated stuff goes there --- // diff --git a/libs/locale/src/shared/message.cpp b/libs/locale/src/shared/message.cpp index 5761f23..1c332c7 100644 --- a/libs/locale/src/shared/message.cpp +++ b/libs/locale/src/shared/message.cpp @@ -567,6 +567,12 @@ namespace boost { mo_catalogs_.resize(domains.size()); plural_forms_.resize(domains.size()); + _info.language(language); + _info.country(country); + _info.variant(variant); + _info.encoding(encoding); + _info.locale_category(lc_cat); + for(unsigned id=0;id(msg,buffer,key_conversion_required_,locale_encoding_,key_encoding_); } + catalog_info get_info(void) const + { + return _info; + } + virtual ~mo_message() { } @@ -746,6 +764,7 @@ namespace boost { std::string locale_encoding_; std::string key_encoding_; bool key_conversion_required_; + catalog_info _info; }; @@ -884,6 +903,37 @@ namespace boost { } + template + catalog_info _get_catalog_info(std::locale const& loc) + { + typedef mo_message facet_type; + if(std::has_facet(loc)) + return std::use_facet(loc).get_info(); + else + return catalog_info(); + } + + template <> + catalog_info get_catalog_info(std::locale const& loc) + { return _get_catalog_info(loc); } + + template <> + catalog_info get_catalog_info(std::locale const& loc) + { return _get_catalog_info(loc); } + + #ifdef BOOST_HAS_CHAR16_T + template <> + catalog_info get_catalog_info(std::locale const& loc) + { return _get_catalog_info(loc); } + #endif + + #ifdef BOOST_HAS_CHAR32_T + template <> + catalog_info get_catalog_info(std::locale const& loc) + { return _get_catalog_info(loc); } + #endif + + std::string catalog_info::language() const { return d->language; } void catalog_info::language(std::string const &v) { d->language=v; }