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. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_LOCLAE_GNU_GETTEXT_HPP
9 #define BOOST_LOCLAE_GNU_GETTEXT_HPP
10 
11 #include <boost/locale/message.hpp>
12 #include <boost/function.hpp>
13 #include <stdexcept>
14 
15 namespace boost {
16 namespace locale {
19 
20 
24 namespace gnu_gettext {
25 
34  struct messages_info {
35  messages_info() :
36  language("C"),
37  locale_category("LC_MESSAGES")
38  {
39  }
40 
41  std::string language;
42  std::string country;
43  std::string variant;
44  std::string encoding;
45  std::string locale_category;
47  struct domain {
56 
57  std::string name;
58  std::string encoding;
59  domain() {}
66  domain(std::string const &n)
67  {
68  size_t pos = n.find("/");
69  if(pos==std::string::npos) {
70  name = n;
71  encoding = "UTF-8";
72  }
73  else {
74  name = n.substr(0,pos);
75  encoding = n.substr(pos+1);
76  }
77 
78  }
79 
83  bool operator==(domain const &other) const
84  {
85  return name==other.name;
86  }
90  bool operator!=(domain const &other) const
91  {
92  return !(*this==other);
93  }
94 
95  };
96 
97  typedef std::vector<domain> domains_type;
100  std::vector<std::string> paths;
102 
114  typedef function<
115  std::vector<char>(
116  std::string const &file_name,
117  std::string const &encoding
118  )
120 
126 
127  };
128 
133 
134  template<typename CharType>
136 
138 
139  template<>
141 
142  template<>
144 
145  #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
146  template<>
148  #endif
149 
150  #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
151  template<>
153  #endif
154 
156 
157 } // gnu_gettext
158 
160 
161 } // locale
162 } // boost
163 
164 #endif
165 
166 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
167 
a facet that holds general information about locale
Definition: info.hpp:27
domains_type domains
Definition: gnu_gettext.hpp:99
bool operator!=(domain const &other) const
Definition: gnu_gettext.hpp:90
std::string encoding
Definition: gnu_gettext.hpp:44
std::string locale_category
Definition: gnu_gettext.hpp:46
This structure holds all information required for creating gnu-gettext message catalogs,.
Definition: gnu_gettext.hpp:34
domain(std::string const &n)
Definition: gnu_gettext.hpp:66
bool operator==(domain const &other) const
Definition: gnu_gettext.hpp:83
std::vector< std::string > paths
Definition: gnu_gettext.hpp:101
This facet provides message formatting abilities.
Definition: message.hpp:47
This type represents GNU Gettext domain name for the messages.
Definition: gnu_gettext.hpp:55
std::string language
The language we load the catalog for, like "ru", "en", "de".
Definition: gnu_gettext.hpp:41
std::vector< domain > domains_type
Definition: gnu_gettext.hpp:97
std::string name
The name of the domain.
Definition: gnu_gettext.hpp:57
function< std::vector< char > std::string const &file_name, std::string const &encoding) > callback_type
Definition: gnu_gettext.hpp:119
callback_type callback
Definition: gnu_gettext.hpp:125
std::string country
The country we load the catalog for, like "US", "IL".
Definition: gnu_gettext.hpp:42
message_format< CharType > * create_messages_facet(messages_info const &info)
std::string variant
Language variant, like "euro" so it would look for catalog like de_DE@euro.
Definition: gnu_gettext.hpp:43
std::string encoding
The character encoding for the domain.
Definition: gnu_gettext.hpp:58