Ticket #7727: boost-gettext_info.patch

File boost-gettext_info.patch, 4.5 KB (added by 166291@…, 10 years ago)
  • boost/locale/gnu_gettext.hpp

    diff --git a/boost/locale/gnu_gettext.hpp b/boost/locale/gnu_gettext.hpp
    index b739cbb..b9bf07e 100644
    a b namespace gnu_gettext {  
    231231    template<typename CharType>
    232232    message_format<CharType> *create_messages_facet(catalog_info const &info);
    233233
     234    ///
     235    /// Gets catalog information from a locale.
     236    ///
     237    template<typename CharType>
     238    catalog_info get_catalog_info(std::locale const& loc);
     239
     240    /// \cond INTERNAL
     241
     242    template<>
     243    BOOST_LOCALE_DECL catalog_info get_catalog_info<char>(std::locale const& loc);
     244   
     245    template<>
     246    BOOST_LOCALE_DECL catalog_info get_catalog_info<wchar_t>(std::locale const& loc);
     247
     248    #ifdef BOOST_HAS_CHAR16_T
     249    template<>
     250    BOOST_LOCALE_DECL catalog_info get_catalog_info<char16_t>(std::locale const& loc);
     251    #endif
     252   
     253    #ifdef BOOST_HAS_CHAR32_T
     254    template<>
     255    BOOST_LOCALE_DECL catalog_info get_catalog_info<char32_t>(std::locale const& loc);
     256    #endif
     257
     258    /// \endcond
    234259
    235260    // ---- deprecated stuff goes there --- //
    236261
  • libs/locale/src/shared/message.cpp

    diff --git a/libs/locale/src/shared/message.cpp b/libs/locale/src/shared/message.cpp
    index 5761f23..1c332c7 100644
    a b namespace boost {  
    567567                    mo_catalogs_.resize(domains.size());
    568568                    plural_forms_.resize(domains.size());
    569569
     570                    _info.language(language);
     571                    _info.country(country);
     572                    _info.variant(variant);
     573                    _info.encoding(encoding);
     574                    _info.locale_category(lc_cat);
     575
    570576
    571577                    for(unsigned id=0;id<domains.size();id++) {
    572578                        std::string domain=domains[id].name();
    namespace boost {  
    580586                                for(unsigned k=0;!found && k<formats.size();k++) {
    581587                                    std::string full_path = (format(formats[k]) % search_paths[i] % paths[j] % lc_cat % domain).str(std::locale::classic());
    582588                                    found = load_file(full_path,encoding,key_encoding,id,inf.callback());
     589
     590                                    if(found)
     591                                    {
     592                                        _info.add_domain(domain);
     593                                        _info.add_path(search_paths[i]);
     594                                        _info.add_path_format(formats[k]);
     595                                    }
    583596                                }
    584597                            }
    585598                        }
    namespace boost {  
    591604                    return runtime_conversion<char_type>(msg,buffer,key_conversion_required_,locale_encoding_,key_encoding_);
    592605                }
    593606
     607                catalog_info get_info(void) const
     608                {
     609                    return _info;
     610                }
     611
    594612                virtual ~mo_message()
    595613                {
    596614                }
    namespace boost {  
    746764                std::string locale_encoding_;
    747765                std::string key_encoding_;
    748766                bool key_conversion_required_;
     767                catalog_info _info;
    749768            };
    750769
    751770
    namespace boost {  
    884903            }
    885904
    886905
     906            template <typename CharType>
     907            catalog_info _get_catalog_info(std::locale const& loc)
     908            {
     909                typedef mo_message<CharType> facet_type;
     910                if(std::has_facet<facet_type>(loc))
     911                    return std::use_facet<facet_type>(loc).get_info();
     912                else
     913                    return catalog_info();
     914            }
     915
     916            template <>
     917            catalog_info get_catalog_info<char>(std::locale const& loc)
     918            { return _get_catalog_info<char>(loc); }
     919
     920            template <>
     921            catalog_info get_catalog_info<wchar_t>(std::locale const& loc)
     922            { return _get_catalog_info<wchar_t>(loc); }
     923
     924            #ifdef BOOST_HAS_CHAR16_T
     925            template <>
     926            catalog_info get_catalog_info<char16_t>(std::locale const& loc)
     927            { return _get_catalog_info<char16_t>(loc); }
     928            #endif
     929
     930            #ifdef BOOST_HAS_CHAR32_T
     931            template <>
     932            catalog_info get_catalog_info<char32_t>(std::locale const& loc)
     933            { return _get_catalog_info<char32_t>(loc); }
     934            #endif
     935
     936
    887937            std::string catalog_info::language() const { return d->language; }
    888938            void catalog_info::language(std::string const &v) { d->language=v; }
    889939