Class WCombinedLocalizedStrings
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).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(WLocalizedStrings resolver) Adds a string resolver.getItems()
void
Purges memory resources, if possible.void
insert
(int index, WLocalizedStrings resolver) Inserts a string resolver.void
remove
(WLocalizedStrings resolver) Removes a string resolver.resolveKey
(Locale locale, String key) Resolves a key in the given locale.resolvePluralKey
(Locale locale, String key, long amount) Resolves the plural form of a key in the given locale.Methods inherited from class eu.webtoolkit.jwt.WLocalizedStrings
evaluatePluralExpression
-
Constructor Details
-
WCombinedLocalizedStrings
public WCombinedLocalizedStrings()Constructor.
-
-
Method Details
-
add
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. -
insert
Inserts a string resolver.- See Also:
-
remove
Removes a string resolver.- See Also:
-
getItems
-
hibernate
public void hibernate()Description copied from class:WLocalizedStrings
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.
- Overrides:
hibernate
in classWLocalizedStrings
-
resolveKey
Description copied from class:WLocalizedStrings
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.- Specified by:
resolveKey
in classWLocalizedStrings
- See Also:
-
resolvePluralKey
Description copied from class:WLocalizedStrings
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 theamount
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.- Overrides:
resolvePluralKey
in classWLocalizedStrings
-