boost::locale::generator Class Reference

the major class used for locale generation More...

`#include <boost/locale/generator.hpp>`

## Public Member Functions

| generator ()
| Create new generator using global localization_backend_manager.
| generator (const localization_backend_manager &)
| Create new generator using specific localization_backend_manager.
void | categories (category_t cats)
| Set types of facets that should be generated, default all.
category_t | categories () const
| Get types of facets that should be generated, default all.
void | characters (char_facet_t chars)
| Set the characters type for which the facets should be generated, default all supported.
char_facet_t | characters () const
| Get the characters type for which the facets should be generated, default all supported.
void | add_messages_domain (const std::string &domain)
void | set_default_messages_domain (const std::string &domain)
void | clear_domains ()
| Remove all added domains from the list.
void | add_messages_path (const std::string &path)
void | clear_paths ()
| Remove all added paths.
void | clear_cache ()
| Remove all cached locales.
void | locale_cache_enabled (bool on)
| Turn locale caching ON.
bool | locale_cache_enabled () const
| Get locale cache option.
bool | use_ansi_encoding () const
| Check if by default ANSI encoding is selected or UTF-8 onces. The default is false.
void | use_ansi_encoding (bool enc)
std::locale | generate (const std::string &id) const
| Generate a locale with id id.
std::locale | generate (const std::locale &base, const std::string &id) const
std::locale | operator() (const std::string &id) const
| Shortcut to generate(id)

## Detailed Description

the major class used for locale generation

This class is used for specification of all parameters required for locale generation and caching. This class const member functions are thread safe if locale class implementation is thread safe.

Examples
  boundary.cpp, calendar.cpp, collate.cpp, conversions.cpp, hello.cpp, wboundary.cpp, wconversions.cpp, and whello.cpp.

## Member Function Documentation

## add_messages_domain()

void boost::locale::generator::add_messages_domain | ( | const std::string & | domain | ) |

Add a new domain of messages that would be generated. It should be set in order to enable messages support.

Messages domain has following format: "name" or "name/encoding" where name is the base name of the "mo" file where the catalog is stored without ".mo" extension. For example for file `/usr/share/locale/he/LC_MESSAGES/blog`.mo it would be `blog`.

You can optionally specify the encoding of the keys in the sources by adding "/encoding_name" For example blog/cp1255.

If not defined all keys are assumed to be UTF-8 encoded.

Note
  When you select a domain for the program using dgettext or message API, you do not specify the encoding part. So for example if the provided domain name was "blog/windows-1255" then for translation you should use dgettext("blog","Hello")

## add_messages_path()

void boost::locale::generator::add_messages_path | ( | const std::string & | path | ) |

Add a search path where dictionaries are looked in.

Note

- Under the Windows platform the path is treated as a path in the locale's encoding so if you create locale "en_US.windows-1251" then path would be treated as cp1255, and if it is en_US.UTF-8 it is treated as UTF-8. File name is always opened with a wide file name as wide file names are the native file name on Windows.
- Under POSIX platforms all paths passed as-is regardless of encoding as narrow encodings are the native encodings for POSIX platforms.

## generate()

std::locale boost::locale::generator::generate | ( | const std::locale & | base,
|  | const std::string & | id
| ) |  | const

Generate a locale with id id. Use base as a locale to which all facets are added, instead of std::locale::classic().

## set_default_messages_domain()

void boost::locale::generator::set_default_messages_domain | ( | const std::string & | domain | ) |

Set default message domain. If this member was not called, the first added messages domain is used. If the domain domain is not added yet it is added.

## use_ansi_encoding()

void boost::locale::generator::use_ansi_encoding | ( | bool | enc | ) |

Select ANSI encodings as default system encoding rather then UTF-8 by default under Windows.

The default is the most portable and most powerful encoding, UTF-8, but the user can select "system" one if dealing with legacy applications

The documentation for this class was generated from the following file:

- boost/locale/generator.hpp

- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.