Boost.Locale
gnu_gettext.hpp
1 //
2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // https://www.boost.org/LICENSE_1_0.txt
6 
7 #ifndef BOOST_LOCLAE_GNU_GETTEXT_HPP
8 #define BOOST_LOCLAE_GNU_GETTEXT_HPP
9 
10 #include <boost/locale/message.hpp>
11 #include <functional>
12 #include <stdexcept>
13 #include <vector>
14 
15 namespace boost { namespace locale {
18 
20  namespace gnu_gettext {
21 
28  struct messages_info {
29  messages_info() : language("C"), locale_category("LC_MESSAGES") {}
30 
31  std::string language;
32  std::string country;
33  std::string variant;
34  std::string encoding;
35  std::string locale_category;
37  struct domain {
46  std::string name;
47  std::string encoding;
48  domain() = default;
49 
54  domain(const std::string& n)
55  {
56  size_t pos = n.find('/');
57  if(pos == std::string::npos) {
58  name = n;
59  encoding = "UTF-8";
60  } else {
61  name = n.substr(0, pos);
62  encoding = n.substr(pos + 1);
63  }
64  }
65 
67  bool operator==(const domain& other) const { return name == other.name; }
69  bool operator!=(const domain& other) const { return !(*this == other); }
70  };
71 
72  typedef std::vector<domain> domains_type;
75  std::vector<std::string> paths;
77 
87  typedef std::function<std::vector<char>(const std::string& file_name, const std::string& encoding)>
89 
93  };
94 
97  template<typename CharType>
99 
101 
102  template<>
104 
105  template<>
107 
108 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
109  template<>
111 #endif
112 
113 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
114  template<>
116 #endif
117 
119 
120  } // namespace gnu_gettext
121 
123 
124 }} // namespace boost::locale
125 
126 #endif
a facet that holds general information about locale
Definition: info.hpp:24
domains_type domains
Definition: gnu_gettext.hpp:74
std::string encoding
Definition: gnu_gettext.hpp:34
std::string locale_category
Definition: gnu_gettext.hpp:36
This structure holds all information required for creating gnu-gettext message catalogs,...
Definition: gnu_gettext.hpp:28
message_format< CharType > * create_messages_facet(const messages_info &info)
std::vector< std::string > paths
Definition: gnu_gettext.hpp:76
This facet provides message formatting abilities.
Definition: message.hpp:48
bool operator!=(const domain &other) const
Check whether two objects are distinct, only names are compared, encoding is ignored.
Definition: gnu_gettext.hpp:69
This type represents GNU Gettext domain name for the messages.
Definition: gnu_gettext.hpp:45
bool operator==(const domain &other) const
Check whether two objects are equivalent, only names are compared, encoding is ignored.
Definition: gnu_gettext.hpp:67
std::string language
The language we load the catalog for, like "ru", "en", "de".
Definition: gnu_gettext.hpp:31
std::vector< domain > domains_type
Definition: gnu_gettext.hpp:72
std::string name
The name of the domain.
Definition: gnu_gettext.hpp:46
callback_type callback
Definition: gnu_gettext.hpp:92
domain(const std::string &n)
Definition: gnu_gettext.hpp:54
std::function< std::vector< char >const std::string &file_name, const std::string &encoding)> callback_type
Definition: gnu_gettext.hpp:88
std::string country
The country we load the catalog for, like "US", "IL".
Definition: gnu_gettext.hpp:32
std::string variant
Language variant, like "euro" so it would look for catalog like de_DE@euro.
Definition: gnu_gettext.hpp:33
std::string encoding
The character encoding for the domain.
Definition: gnu_gettext.hpp:47