Boost.Locale
Message Formatting (translation)

Classes

class  boost::locale::message_format< CharType >
 This facet provides message formatting abilities. More...
class  boost::locale::basic_message< CharType >
 This class represents a message that can be converted to a specific locale message. More...

Namespaces

namespace  boost::locale::gnu_gettext
 

This namespace holds classes that provide GNU Gettext message catalogs support.


namespace  boost::locale::as
 

This namespace includes all manipulators that can be used on IO streams.


Modules

 I/O Stream manipulators

Typedefs

typedef CharType boost::locale::message_format< CharType >::char_type
typedef std::basic_string
< CharType > 
boost::locale::message_format< CharType >::string_type
typedef CharType boost::locale::basic_message< CharType >::char_type
 The character this message object is used with.
typedef std::basic_string
< char_type > 
boost::locale::basic_message< CharType >::string_type
 The string type this object can be used with.
typedef message_format< char_type > boost::locale::basic_message< CharType >::facet_type
 The type of the facet the messages are fetched with.
typedef basic_message< char > boost::locale::message
typedef basic_message< wchar_t > boost::locale::wmessage
typedef basic_message< char16_t > boost::locale::u16message
typedef basic_message< char32_t > boost::locale::u32message

Functions

 boost::locale::message_format< CharType >::message_format (size_t refs=0)
virtual char_type const * boost::locale::message_format< CharType >::get (int domain_id, char_type const *context, char_type const *id) const =0
virtual char_type const * boost::locale::message_format< CharType >::get (int domain_id, char_type const *context, char_type const *single_id, int n) const =0
virtual int boost::locale::message_format< CharType >::domain (std::string const &domain) const =0
virtual char_type const * boost::locale::message_format< CharType >::convert (char_type const *msg, string_type &buffer) const =0
 boost::locale::basic_message< CharType >::basic_message ()
 boost::locale::basic_message< CharType >::basic_message (char_type const *id)
 boost::locale::basic_message< CharType >::basic_message (char_type const *single, char_type const *plural, int n)
 boost::locale::basic_message< CharType >::basic_message (char_type const *context, char_type const *id)
 boost::locale::basic_message< CharType >::basic_message (char_type const *context, char_type const *single, char_type const *plural, int n)
 boost::locale::basic_message< CharType >::basic_message (string_type const &id)
 boost::locale::basic_message< CharType >::basic_message (string_type const &single, string_type const &plural, int number)
 boost::locale::basic_message< CharType >::basic_message (string_type const &context, string_type const &id)
 boost::locale::basic_message< CharType >::basic_message (string_type const &context, string_type const &single, string_type const &plural, int number)
 boost::locale::basic_message< CharType >::basic_message (basic_message const &other)
basic_message const & boost::locale::basic_message< CharType >::operator= (basic_message const &other)
void boost::locale::basic_message< CharType >::swap (basic_message &other)
 boost::locale::basic_message< CharType >::operator string_type () const
string_type boost::locale::basic_message< CharType >::str () const
string_type boost::locale::basic_message< CharType >::str (std::locale const &locale) const
string_type boost::locale::basic_message< CharType >::str (std::locale const &locale, std::string const &domain_id) const
string_type boost::locale::basic_message< CharType >::str (std::string const &domain_id) const
string_type boost::locale::basic_message< CharType >::str (std::locale const &loc, int id) const
void boost::locale::basic_message< CharType >::write (std::basic_ostream< char_type > &out) const
template<typename CharType >
std::basic_ostream< CharType > & boost::locale::operator<< (std::basic_ostream< CharType > &out, basic_message< CharType > const &msg)

Indirect message translation function family

template<typename CharType >
basic_message< CharType > boost::locale::translate (CharType const *msg)
 Translate a message, msg is not copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (CharType const *context, CharType const *msg)
 Translate a message in context, msg and context are not copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (CharType const *single, CharType const *plural, int n)
 Translate a plural message form, single and plural are not copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (CharType const *context, CharType const *single, CharType const *plural, int n)
 Translate a plural message from in constext, context, single and plural are not copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (std::basic_string< CharType > const &msg)
 Translate a message, msg is copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (std::basic_string< CharType > const &context, std::basic_string< CharType > const &msg)
 Translate a message in context,context and msg is copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (std::basic_string< CharType > const &context, std::basic_string< CharType > const &single, std::basic_string< CharType > const &plural, int n)
 Translate a plural message form in constext, context, single and plural are copied.
template<typename CharType >
basic_message< CharType > boost::locale::translate (std::basic_string< CharType > const &single, std::basic_string< CharType > const &plural, int n)
 Translate a plural message form, single and plural are copied.

Direct message translation functions family

template<typename CharType >
std::basic_string< CharType > boost::locale::gettext (CharType const *id, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::ngettext (CharType const *s, CharType const *p, int n, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::dgettext (char const *domain, CharType const *id, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::dngettext (char const *domain, CharType const *s, CharType const *p, int n, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::pgettext (CharType const *context, CharType const *id, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::npgettext (CharType const *context, CharType const *s, CharType const *p, int n, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::dpgettext (char const *domain, CharType const *context, CharType const *id, std::locale const &loc=std::locale())
template<typename CharType >
std::basic_string< CharType > boost::locale::dnpgettext (char const *domain, CharType const *context, CharType const *s, CharType const *p, int n, std::locale const &loc=std::locale())

Detailed Description

This module provides message translation functionality, i.e. allow your application to speak native language


Typedef Documentation

template<typename CharType>
typedef CharType boost::locale::message_format< CharType >::char_type

Character type

typedef basic_message<char> boost::locale::message

Convenience typedef for char

template<typename CharType>
typedef std::basic_string<CharType> boost::locale::message_format< CharType >::string_type

String type

typedef basic_message<char16_t> boost::locale::u16message

Convenience typedef for char16_t

typedef basic_message<char32_t> boost::locale::u32message

Convenience typedef for char32_t

typedef basic_message<wchar_t> boost::locale::wmessage

Convenience typedef for wchar_t


Function Documentation

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( ) [inline]

Create default empty message

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( char_type const *  id) [inline, explicit]

Create a simple message from 0 terminated string. The string should exist until the message is destroyed. Generally useful with static constant strings

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( char_type const *  single,
char_type const *  plural,
int  n 
) [inline, explicit]

Create a simple plural form message from 0 terminated strings. The strings should exist until the message is destroyed. Generally useful with static constant strings.

n is the number, single and plural are singular and plural forms of the message

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( char_type const *  context,
char_type const *  id 
) [inline, explicit]

Create a simple message from 0 terminated strings, with context information. The string should exist until the message is destroyed. Generally useful with static constant strings

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( char_type const *  context,
char_type const *  single,
char_type const *  plural,
int  n 
) [inline, explicit]

Create a simple plural form message from 0 terminated strings, with context. The strings should exist until the message is destroyed. Generally useful with static constant strings.

n is the number, single and plural are singular and plural forms of the message

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( string_type const &  id) [inline, explicit]

Create a simple message from a string.

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( string_type const &  single,
string_type const &  plural,
int  number 
) [inline, explicit]

Create a simple plural form message from strings.

n is the number, single and plural are single and plural forms of the message

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( string_type const &  context,
string_type const &  id 
) [inline, explicit]

Create a simple message from a string with context.

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( string_type const &  context,
string_type const &  single,
string_type const &  plural,
int  number 
) [inline, explicit]

Create a simple plural form message from strings.

n is the number, single and plural are single and plural forms of the message

template<typename CharType>
boost::locale::basic_message< CharType >::basic_message ( basic_message< CharType > const &  other) [inline]

Copy an object

template<typename CharType>
virtual char_type const* boost::locale::message_format< CharType >::convert ( char_type const *  msg,
string_type buffer 
) const [pure virtual]

Convert the string msg to target locale's encoding. If msg is already in target encoding it would be returned otherwise the converted string is stored in temporary buffer and buffer.c_str() is returned.

Note: for char_type that is char16_t, char32_t and wchar_t it is no-op, returns msg

template<typename CharType >
std::basic_string<CharType> boost::locale::dgettext ( char const *  domain,
CharType const *  id,
std::locale const &  loc = std::locale() 
)

Translate message id according to locale loc in domain domain

template<typename CharType >
std::basic_string<CharType> boost::locale::dngettext ( char const *  domain,
CharType const *  s,
CharType const *  p,
int  n,
std::locale const &  loc = std::locale() 
)

Translate plural form according to locale loc in domain domain

template<typename CharType >
std::basic_string<CharType> boost::locale::dnpgettext ( char const *  domain,
CharType const *  context,
CharType const *  s,
CharType const *  p,
int  n,
std::locale const &  loc = std::locale() 
)

Translate plural form according to locale loc in domain domain in context context

template<typename CharType>
virtual int boost::locale::message_format< CharType >::domain ( std::string const &  domain) const [pure virtual]

Convert a string that defines domain to the integer id used by get functions

template<typename CharType >
std::basic_string<CharType> boost::locale::dpgettext ( char const *  domain,
CharType const *  context,
CharType const *  id,
std::locale const &  loc = std::locale() 
)

Translate message id according to locale loc in domain domain in context context

template<typename CharType>
virtual char_type const* boost::locale::message_format< CharType >::get ( int  domain_id,
char_type const *  context,
char_type const *  id 
) const [pure virtual]

This function returns a pointer to the string for a message defined by a context and identification string id. Both create a single key for message lookup in a domain defined by domain_id.

If context is NULL it is not considered to be a part of the key

If a translated string is found, it is returned, otherwise NULL is returned

template<typename CharType>
virtual char_type const* boost::locale::message_format< CharType >::get ( int  domain_id,
char_type const *  context,
char_type const *  single_id,
int  n 
) const [pure virtual]

This function returns a pointer to the string for a plural message defined by a context and identification string single_id.

If context is NULL it is not considered to be a part of the key

Both create a single key for message lookup in a domain defined domain_id. n is used to pick the correct translation string for a specific number.

If a translated string is found, it is returned, otherwise NULL is returned

template<typename CharType >
std::basic_string<CharType> boost::locale::gettext ( CharType const *  id,
std::locale const &  loc = std::locale() 
)

Translate message id according to locale loc

template<typename CharType>
boost::locale::message_format< CharType >::message_format ( size_t  refs = 0) [inline]

Default constructor

template<typename CharType >
std::basic_string<CharType> boost::locale::ngettext ( CharType const *  s,
CharType const *  p,
int  n,
std::locale const &  loc = std::locale() 
)

Translate plural form according to locale loc

template<typename CharType >
std::basic_string<CharType> boost::locale::npgettext ( CharType const *  context,
CharType const *  s,
CharType const *  p,
int  n,
std::locale const &  loc = std::locale() 
)

Translate plural form according to locale loc in context context

template<typename CharType>
boost::locale::basic_message< CharType >::operator string_type ( ) const [inline]

Message class can be explicitly converted to string class

template<typename CharType >
std::basic_ostream<CharType>& boost::locale::operator<< ( std::basic_ostream< CharType > &  out,
basic_message< CharType > const &  msg 
)

Translate message msg and write it to stream

template<typename CharType>
basic_message const& boost::locale::basic_message< CharType >::operator= ( basic_message< CharType > const &  other) [inline]

Assign other message object to this one

template<typename CharType >
std::basic_string<CharType> boost::locale::pgettext ( CharType const *  context,
CharType const *  id,
std::locale const &  loc = std::locale() 
)

Translate message id according to locale loc in context context

template<typename CharType>
string_type boost::locale::basic_message< CharType >::str ( ) const [inline]

Translate message to a string in the default global locale, using default domain

template<typename CharType>
string_type boost::locale::basic_message< CharType >::str ( std::locale const &  locale) const [inline]

Translate message to a string in the locale locale, using default domain

template<typename CharType>
string_type boost::locale::basic_message< CharType >::str ( std::locale const &  locale,
std::string const &  domain_id 
) const [inline]

Translate message to a string using locale locale and message domain domain_id

template<typename CharType>
string_type boost::locale::basic_message< CharType >::str ( std::string const &  domain_id) const [inline]

Translate message to a string using the default locale and message domain domain_id

template<typename CharType>
string_type boost::locale::basic_message< CharType >::str ( std::locale const &  loc,
int  id 
) const [inline]

Translate message to a string using locale loc and message domain index id

template<typename CharType>
void boost::locale::basic_message< CharType >::swap ( basic_message< CharType > &  other) [inline]

Swap two message objects

template<typename CharType>
void boost::locale::basic_message< CharType >::write ( std::basic_ostream< char_type > &  out) const [inline]

Translate message and write to stream out, using imbued locale and domain set to the stream