From Cppreference
|
|
|
|
|
template< class charT > class messages;
|
|
|
|
|
Class std::messages encapsulates retrieval of strings from message catalogs, such as the ones provided by GNU gettext or by POSIX catgets.
Two specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
Defined in header <locale>
|
|
std::messages<char>
|
accesses narrow string message catalog
|
|
std::codecvt<wchar_t>
|
accesses wide string message catalog
|
[edit] Member types
|
Member type
|
Definition
|
|
char_type
|
charT
|
|
string_type
|
std::basic_string<charT>
|
[edit] Member objects
|
Member name
|
Type
|
|
id (static)
|
std::locale::id
|
[edit] Member functions
|
|
constructs a new messages facet (public member function)
|
|
|
destructs a messages facet (protected member function)
|
Public member functions (pubic interface)
|
|
|
invokes do_open (public member function)
|
|
|
invokes do_get (public member function)
|
|
|
invokes do_close (public member function)
|
Virtual member functions (can be overridden in a user-defined facet derived from codecvt
|
|
|
opens a named message catalog (virtual protected member function)
|
|
|
retrieves a message from an open message catalog (virtual protected member function)
|
|
|
closes a message catalog (virtual protected member function)
|
Inherited from std::messages_base
|
Type
|
Definition
|
|
catalog
|
int
|
[edit] Example
The following example demonstrated retrieval of GNU gettext messages
#include <iostream>
#include <locale>
int main()
{
std::locale loc("de_DE");
auto& facet = std::use_facet<std::messages<char>>(loc);
const char* dir = "/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.1/locale";
auto cat = facet.open("libstdc++", loc, dir);
std::cout << "\"please\" in German: "
<< facet.get(cat, 0, 0, "please") << '\n'
<< "\"thank you\" in German: "
<< facet.get(cat, 0, 0, "thank you") << '\n';
facet.close(cat);
}
Output:
"please" in German: bitte
"thank you" in German: danke
[edit] See also
|
|
defines messages catalog type (class template)
|
|
|
creates a messages facet for the named locale (class template)
|