CppCMS
gnu_gettext.h
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 BOOSTER_LOCLAE_GNU_GETTEXT_HPP
9 #define BOOSTER_LOCLAE_GNU_GETTEXT_HPP
10 
11 #include <booster/locale/message.h>
12 #include <booster/function.h>
13 #include <booster/backtrace.h>
14 
15 namespace booster {
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;
98  domains_type domains;
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 BOOSTER_HAS_CHAR16_T
146  template<>
148  #endif
149 
150  #ifdef BOOSTER_HAS_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 
callback_type callback
Definition: gnu_gettext.h:125
std::string variant
Language variant, like "euro" so it would look for catalog like de_DE@euro.
Definition: gnu_gettext.h:43
bool operator==(domain const &other) const
Definition: gnu_gettext.h:83
This type represents GNU Gettext domain name for the messages.
Definition: gnu_gettext.h:55
std::string language
The language we load the catalog for, like "ru", "en", "de".
Definition: gnu_gettext.h:41
This facet provides message formatting abilities.
Definition: message.h:47
std::string locale_category
Definition: gnu_gettext.h:46
std::string country
The country we load the catalog for, like "US", "IL".
Definition: gnu_gettext.h:42
std::string name
The name of the domain.
Definition: gnu_gettext.h:57
std::string encoding
Definition: gnu_gettext.h:44
std::vector< domain > domains_type
Definition: gnu_gettext.h:97
message_format< CharType > * create_messages_facet(messages_info const &info)
domains_type domains
Definition: gnu_gettext.h:99
std::vector< std::string > paths
Definition: gnu_gettext.h:101
domain(std::string const &n)
Definition: gnu_gettext.h:66
This is the main namespace that encloses all localization classes.
Definition: locale_fwd.h:14
Definition: function.h:16
a facet that holds general information about locale
Definition: info.h:27
This structure holds all information required for creating gnu-gettext message catalogs,.
Definition: gnu_gettext.h:34
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
std::string encoding
The character encoding for the domain.
Definition: gnu_gettext.h:58
bool operator!=(domain const &other) const
Definition: gnu_gettext.h:90