CppCMS

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

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
booster::locale::generator Class Reference

the major class used for locale generation More...

`#include <booster/booster/locale/generator.h>`

## Public Member Functions
| generator ()
| generator (localization_backend_manager const &)
void | categories (locale_category_type cats)
locale_category_type | categories () const
void | characters (character_facet_type chars)
character_facet_type | characters () const
void | add_messages_domain (std::string const &domain)
void | set_default_messages_domain (std::string const &domain)
void | clear_domains ()
void | add_messages_path (std::string const &path)
void | clear_paths ()
void | clear_cache ()
void | locale_cache_enabled (bool on)
bool | locale_cache_enabled () const
bool | use_ansi_encoding () const
void | use_ansi_encoding (bool enc)
std::locale | generate (std::string const &id) const
std::locale | generate (std::locale const &base, std::string const &id) const
std::locale | operator() (std::string const &id) const
void | set_option (std::string const &name, std::string const &value)
void | clear_options ()

## 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.

## Constructor & Destructor Documentation

booster::locale::generator::generator | ( |  | ) |

Create new generator using global localization_backend_manager

booster::locale::generator::generator | ( | localization_backend_manager const & |  | ) |

Create new generator using specific localization_backend_manager

## Member Function Documentation

void booster::locale::generator::add_messages_domain | ( | std::string const & | 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")

void booster::locale::generator::add_messages_path | ( | std::string const & | 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.

void booster::locale::generator::categories | ( | locale_category_type | cats | ) |

Set types of facets that should be generated, default all

locale_category_type booster::locale::generator::categories | ( |  | ) | const

Get types of facets that should be generated, default all

void booster::locale::generator::characters | ( | character_facet_type | chars | ) |

Set the characters type for which the facets should be generated, default all supported

character_facet_type booster::locale::generator::characters | ( |  | ) | const

Get the characters type for which the facets should be generated, default all supported

void booster::locale::generator::clear_cache | ( |  | ) |

Remove all cached locales

void booster::locale::generator::clear_domains | ( |  | ) |

Remove all added domains from the list

void booster::locale::generator::clear_options | ( |  | ) |

Clear backend specific options

void booster::locale::generator::clear_paths | ( |  | ) |

Remove all added paths

std::locale booster::locale::generator::generate | ( | std::string const & | id | ) | const

Generate a locale with id id

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

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

void booster::locale::generator::locale_cache_enabled | ( | bool | on | ) |

Turn locale caching ON

bool booster::locale::generator::locale_cache_enabled | ( |  | ) | const

Get locale cache option

std::locale booster::locale::generator::operator() | ( | std::string const & | id | ) | const
| inline

Shortcut to generate(id)

void booster::locale::generator::set_default_messages_domain | ( | std::string const & | 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.

void booster::locale::generator::set_option | ( | std::string const & | name,
|  | std::string const & | value
| ) |  |

Set backend specific option

bool booster::locale::generator::use_ansi_encoding | ( |  | ) | const

Check if by default ANSI encoding is selected or UTF-8 onces. The default is false.

void booster::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:

- booster/locale/generator.h