Wt  4.0.2
Public Member Functions | Static Public Member Functions | List of all members
Wt::WLocalizedStrings Class Referenceabstract

An abstract class that provides support for localized strings. More...

#include <Wt/WLocalizedStrings.h>

Inheritance diagram for Wt::WLocalizedStrings:
Inheritance graph
[legend]

Public Member Functions

virtual ~WLocalizedStrings ()
 Destructor.
 
virtual void hibernate ()
 Purges memory resources, if possible. More...
 
virtual LocalizedString resolveKey (const WLocale &locale, const std::string &key)=0
 Resolves a key in the given locale. More...
 
virtual LocalizedString resolvePluralKey (const WLocale &locale, const std::string &key,::uint64_t amount)
 Resolves the plural form of a key in the given locale. More...
 

Static Public Member Functions

static int evaluatePluralExpression (const std::string &expression,::uint64_t n)
 Utility method to evaluate a plural expression. More...
 

Detailed Description

An abstract class that provides support for localized strings.

This abstract class provides the content to localized WStrings, by resolving the key to a string using the current application locale.

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

Member Function Documentation

int Wt::WLocalizedStrings::evaluatePluralExpression ( const std::string &  expression,
::uint64_t  n 
)
static

Utility method to evaluate a plural expression.

This evaluates C expressions such as used by ngettext for a particular value, which can be useful to implement plural key resolution.

See also
resolvePluralKey()
void Wt::WLocalizedStrings::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 in Wt::WMessageResourceBundle, and Wt::WCombinedLocalizedStrings.

virtual LocalizedString Wt::WLocalizedStrings::resolveKey ( const WLocale locale,
const std::string &  key 
)
pure virtual

Resolves a key in the given locale.

This method is used by WString to obtain the UTF-8 value corresponding to a key in the given locale.

Returns a successful LocalizedString if the key could be resolved.

See also
WString::tr()

Implemented in Wt::WMessageResourceBundle, and Wt::WCombinedLocalizedStrings.

LocalizedString Wt::WLocalizedStrings::resolvePluralKey ( const WLocale locale,
const std::string &  key,
::uint64_t  amount 
)
virtual

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

This method is used by WString to obtain the UTF-8 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 a successful LocalizedString if the key could be resolved.

See also
WString::trn()

Reimplemented in Wt::WMessageResourceBundle, and Wt::WCombinedLocalizedStrings.


Generated on Fri Nov 24 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11