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/message.hpp>
#include <functional>
#include <stdexcept>
#include <vector>
namespace boost { namespace locale {
namespace gnu_gettext {
struct 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)
{
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;
};
template<typename CharType>
message_format<CharType>* create_messages_facet(const messages_info& info);
template<>
BOOST_LOCALE_DECL message_format<char>* create_messages_facet(const messages_info& info);
template<>
BOOST_LOCALE_DECL message_format<wchar_t>* create_messages_facet(const messages_info& info);
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
template<>
BOOST_LOCALE_DECL message_format<char16_t>* create_messages_facet(const messages_info& info);
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR32_T
template<>
BOOST_LOCALE_DECL message_format<char32_t>* create_messages_facet(const messages_info& info);
#endif
} // namespace gnu_gettext
}} // namespace boost::locale
#endif
boost::locale::info
a facet that holds general information about locale
Definition: info.hpp:24
boost::locale::gnu_gettext::messages_info::domains
domains_type domains
Definition: gnu_gettext.hpp:74
boost::locale::gnu_gettext::messages_info::encoding
std::string encoding
Definition: gnu_gettext.hpp:34
boost::locale::gnu_gettext::messages_info::locale_category
std::string locale_category
Definition: gnu_gettext.hpp:36
boost::locale::gnu_gettext::messages_info
This structure holds all information required for creating gnu-gettext message catalogs,...
Definition: gnu_gettext.hpp:28
boost::locale::gnu_gettext::create_messages_facet
message_format< CharType > * create_messages_facet(const messages_info &info)
boost::locale::gnu_gettext::messages_info::paths
std::vector< std::string > paths
Definition: gnu_gettext.hpp:76
boost::locale::message_format
This facet provides message formatting abilities.
Definition: message.hpp:48
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:69
boost::locale::gnu_gettext::messages_info::domain
This type represents GNU Gettext domain name for the messages.
Definition: gnu_gettext.hpp:45
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:67
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:31
boost::locale::gnu_gettext::messages_info::domains_type
std::vector< domain > domains_type
Definition: gnu_gettext.hpp:72
boost::locale::gnu_gettext::messages_info::domain::name
std::string name
The name of the domain.
Definition: gnu_gettext.hpp:46
boost::locale::gnu_gettext::messages_info::callback
callback_type callback
Definition: gnu_gettext.hpp:92
boost::locale::gnu_gettext::messages_info::domain::domain
domain(const std::string &n)
Definition: gnu_gettext.hpp:54
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:88
boost::locale::gnu_gettext::messages_info::country
std::string country
The country we load the catalog for, like "US", "IL".
Definition: gnu_gettext.hpp:32
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:33
boost::locale::gnu_gettext::messages_info::domain::encoding
std::string encoding
The character encoding for the domain.
Definition: gnu_gettext.hpp:47
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.