gnu_gettext.hpp
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_LOCLAE_GNU_GETTEXT_HPP
#define BOOST_LOCLAE_GNU_GETTEXT_HPP
#include <boost/locale/detail/is_supported_char.hpp>
#include <boost/locale/message.hpp>
#include <functional>
#include <stdexcept>
#include <type_traits>
#include <vector>
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4251) // "identifier" : class "type" needs to have dll-interface...
#endif
namespace boost { namespace locale {
namespace gnu_gettext {
struct BOOST_LOCALE_DECL messages_info {
messages_info() : language("C"), locale_category("LC_MESSAGES") {}
std::string language;
std::string country;
std::string variant;
std::string encoding;
std::string locale_category;
struct domain {
std::string name;
std::string encoding;
domain() = default;
domain(const std::string& n)
{
const size_t pos = n.find('/');
if(pos == std::string::npos) {
name = n;
encoding = "UTF-8";
} else {
name = n.substr(0, pos);
encoding = n.substr(pos + 1);
}
}
bool operator==(const domain& other) const { return name == other.name; }
bool operator!=(const domain& other) const { return !(*this == other); }
};
typedef std::vector<domain> domains_type;
domains_type domains;
std::vector<std::string> paths;
typedef std::function<std::vector<char>(const std::string& file_name, const std::string& encoding)>
callback_type;
callback_type callback;
std::vector<std::string> get_catalog_paths() const;
private:
std::vector<std::string> get_lang_folders() const;
};
template<typename CharType, class = boost::locale::detail::enable_if_is_supported_char<CharType>>
BOOST_LOCALE_DECL message_format<CharType>* create_messages_facet(const messages_info& info);
} // namespace gnu_gettext
}} // namespace boost::locale
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
#endif
boost::locale::info
a facet that holds general information about locale
Definition: info.hpp:26
boost::locale::message_format
This facet provides message formatting abilities.
Definition: message.hpp:49
boost::locale::gnu_gettext::create_messages_facet
message_format< CharType > * create_messages_facet(const messages_info &info)
boost::locale::gnu_gettext::messages_info::domain
This type represents GNU Gettext domain name for the messages.
Definition: gnu_gettext.hpp:52
boost::locale::gnu_gettext::messages_info::domain::domain
domain(const std::string &n)
Definition: gnu_gettext.hpp:61
boost::locale::gnu_gettext::messages_info::domain::operator!=
bool operator!=(const domain &other) const
Check whether two objects are distinct, only names are compared, encoding is ignored.
Definition: gnu_gettext.hpp:76
boost::locale::gnu_gettext::messages_info::domain::encoding
std::string encoding
The character encoding for the domain.
Definition: gnu_gettext.hpp:54
boost::locale::gnu_gettext::messages_info::domain::operator==
bool operator==(const domain &other) const
Check whether two objects are equivalent, only names are compared, encoding is ignored.
Definition: gnu_gettext.hpp:74
boost::locale::gnu_gettext::messages_info::domain::name
std::string name
The name of the domain.
Definition: gnu_gettext.hpp:53
boost::locale::gnu_gettext::messages_info
This structure holds all information required for creating gnu-gettext message catalogs,...
Definition: gnu_gettext.hpp:35
boost::locale::gnu_gettext::messages_info::language
std::string language
The language we load the catalog for, like "ru", "en", "de".
Definition: gnu_gettext.hpp:38
boost::locale::gnu_gettext::messages_info::domains
domains_type domains
Definition: gnu_gettext.hpp:81
boost::locale::gnu_gettext::messages_info::get_catalog_paths
std::vector< std::string > get_catalog_paths() const
Get paths to folders which may contain catalog files.
boost::locale::gnu_gettext::messages_info::paths
std::vector< std::string > paths
Definition: gnu_gettext.hpp:83
boost::locale::gnu_gettext::messages_info::locale_category
std::string locale_category
Definition: gnu_gettext.hpp:43
boost::locale::gnu_gettext::messages_info::callback_type
std::function< std::vector< char >(const std::string &file_name, const std::string &encoding)> callback_type
Definition: gnu_gettext.hpp:95
boost::locale::gnu_gettext::messages_info::encoding
std::string encoding
Definition: gnu_gettext.hpp:41
boost::locale::gnu_gettext::messages_info::callback
callback_type callback
Definition: gnu_gettext.hpp:99
boost::locale::gnu_gettext::messages_info::domains_type
std::vector< domain > domains_type
Definition: gnu_gettext.hpp:79
boost::locale::gnu_gettext::messages_info::country
std::string country
The country we load the catalog for, like "US", "IL".
Definition: gnu_gettext.hpp:39
boost::locale::gnu_gettext::messages_info::variant
std::string variant
Language variant, like "euro" so it would look for catalog like de_DE@euro.
Definition: gnu_gettext.hpp:40
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.