| Boost.Locale

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List

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;
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 )
119 > callback_type;
120
125 callback_type callback;
126
127 };
128
133
134 template<typename CharType>
135 message_format<CharType> *create_messages_facet(messages_info const &info);
136
138
139 template<>
140 BOOST_LOCALE_DECL message_format<char> *create_messages_facet(messages_info const &info);
141
142 template<>
143 BOOST_LOCALE_DECL message_format<wchar_t> *create_messages_facet(messages_info const &info);
144
145 #ifdef BOOST_LOCALE_ENABLE_CHAR16_T
146 template<>
147 BOOST_LOCALE_DECL message_format<char16_t> *create_messages_facet(messages_info const &info);
148 #endif
149
150 #ifdef BOOST_LOCALE_ENABLE_CHAR32_T
151 template<>
152 BOOST_LOCALE_DECL message_format<char32_t> *create_messages_facet(messages_info const &info);
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
boost::locale::info
a facet that holds general information about locale
Definition: info.hpp:27
boost::locale::gnu_gettext::messages_info::domains
domains_type domains
Definition: gnu_gettext.hpp:99
boost::locale::gnu_gettext::messages_info::domain::operator!=
bool operator!=(domain const &other) const
Definition: gnu_gettext.hpp:90
boost::locale::gnu_gettext::messages_info::encoding
std::string encoding
Definition: gnu_gettext.hpp:44
boost::locale::gnu_gettext::messages_info::locale_category
std::string locale_category
Definition: gnu_gettext.hpp:46
boost::locale::gnu_gettext::messages_info
This structure holds all information required for creating gnu-gettext message catalogs,.
Definition: gnu_gettext.hpp:34
boost::locale::gnu_gettext::messages_info::domain::domain
domain(std::string const &n)
Definition: gnu_gettext.hpp:66
boost::locale::gnu_gettext::messages_info::domain::operator==
bool operator==(domain const &other) const
Definition: gnu_gettext.hpp:83
boost::locale::gnu_gettext::messages_info::paths
std::vector< std::string > paths
Definition: gnu_gettext.hpp:101
boost::locale::message_format
This facet provides message formatting abilities.
Definition: message.hpp:47
boost::locale::gnu_gettext::messages_info::domain
This type represents GNU Gettext domain name for the messages.
Definition: gnu_gettext.hpp:55
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:41
boost::locale::gnu_gettext::messages_info::domains_type
std::vector< domain > domains_type
Definition: gnu_gettext.hpp:97
boost::locale::gnu_gettext::messages_info::domain::name
std::string name
The name of the domain.
Definition: gnu_gettext.hpp:57
boost::locale::gnu_gettext::messages_info::callback_type
function< std::vector< char > std::string const &file_name, std::string const &encoding) > callback_type
Definition: gnu_gettext.hpp:119
boost::locale::gnu_gettext::messages_info::callback
callback_type callback
Definition: gnu_gettext.hpp:125
boost::locale::gnu_gettext::messages_info::country
std::string country
The country we load the catalog for, like "US", "IL".
Definition: gnu_gettext.hpp:42
boost::locale::gnu_gettext::create_messages_facet
message_format< CharType > * create_messages_facet(messages_info const &info)
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:43
boost::locale::gnu_gettext::messages_info::domain::encoding
std::string encoding
The character encoding for the domain.
Definition: gnu_gettext.hpp:58
- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.