Wt: Wt::WCombinedLocalizedStrings Class Reference

Wt 3.3.0

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

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::WCombinedLocalizedStrings Class Reference

A localized string resolver that bundles multiple string resolvers. More...

`#include <Wt/WCombinedLocalizedStrings>`

Inheritance diagram for Wt::WCombinedLocalizedStrings:
[legend]

List of all members.

## Public Member Functions
| WCombinedLocalizedStrings ()
| Constructor.
void | add (WLocalizedStrings *resolver)
| Adds a string resolver.
void | insert (int index, WLocalizedStrings *resolver)
| Inserts a string resolver.
void | remove (WLocalizedStrings *resolver)
| Removes a string resolver.
const std::vector < WLocalizedStrings * > & | items () const
| Returns the list of resolvers.
virtual void | refresh ()
| Rereads the message resources.
virtual void | hibernate ()
| Purges memory resources, if possible.
virtual bool | resolveKey (const std::string &key, std::string &result)
| Resolves a key in the current locale.
virtual bool | resolvePluralKey (const std::string &key, std::string &result,::uint64_t amount)
| Resolves the plural form of a key in the current locale.

## Detailed Description

A localized string resolver that bundles multiple string resolvers.

This class implements the localized strings interface and delegates WString::tr() string resolution to one or more string resolvers. You will typically use this class if you want to combine different methods of string resolution (e.g. some from files, and other strings using a database).

See also:
  WApplication::setLocalizedStrings()

## Member Function Documentation

void Wt::WCombinedLocalizedStrings::add | ( | WLocalizedStrings * | resolver | ) |

Adds a string resolver.

The order in which string resolvers are added is significant: resolveKey() will consult each string resolver in the order they have been added, until a match is found.

Ownership of the resolver is transferred.

void Wt::WCombinedLocalizedStrings::hibernate | ( |  | ) | `[virtual]`

Purges memory resources, if possible.

This is called afer event handling, and is an opportunity to conserve memory inbetween events, by freeing memory used for cached key/value bindings, if applicable.

The default implementation does nothing.

Reimplemented from Wt::WLocalizedStrings.

void Wt::WCombinedLocalizedStrings::insert | ( | int | index,
|  | WLocalizedStrings * | resolver
| ) |  |

Inserts a string resolver.

See also:
  add()

const std::vector< WLocalizedStrings * > & Wt::WCombinedLocalizedStrings::items | ( |  | ) | const

Returns the list of resolvers.

See also:
  add(), remove()

void Wt::WCombinedLocalizedStrings::refresh | ( |  | ) | `[virtual]`

Rereads the message resources.

Purge any cached key/values, if applicable.

The default implementation does nothing.

Reimplemented from Wt::WLocalizedStrings.

void Wt::WCombinedLocalizedStrings::remove | ( | WLocalizedStrings * | resolver | ) |

Removes a string resolver.

This returns ownership of the resolver.

See also:
  add()

bool Wt::WCombinedLocalizedStrings::resolveKey | ( | const std::string & | key,
|  | std::string & | result
| ) |  | `[virtual]`

Resolves a key in the current locale.

This method is used by WString to obtain the UTF8 value corresponding to a key in the current locale.

Returns `true` if the key could be resolved. The value is written in `result`, encoded using UTF8.

See also:
  WApplication::locale(), WString::tr()

Implements Wt::WLocalizedStrings.

bool Wt::WCombinedLocalizedStrings::resolvePluralKey | ( | const std::string & | key,
|  | std::string & | result,
|  | ::uint64_t | amount
| ) |  | `[virtual]`

Resolves the plural form of a key in the current locale.

This method is used by WString to obtain the UTF8 value corresponding to a key in the current locale, taking into account the possibility of multiple plural forms, and chosing the right plural form based on the `amount` passed.

Throws a std::logic_error if the underlying implementation does not provide support for plural internationalized strings.

Returns `true` if the key could be resolved. The value is written in `result`, encoded as UTF8.

See also:
  WApplication::locale(), WString::trn()

Reimplemented from Wt::WLocalizedStrings.

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator