Class WCombinedLocalizedStrings


  • public class WCombinedLocalizedStrings
    extends WLocalizedStrings
    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(WLocalizedStrings translator)
    • Constructor Detail

      • WCombinedLocalizedStrings

        public WCombinedLocalizedStrings()
        Constructor.
    • Method Detail

      • add

        public void 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.

      • 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 class WLocalizedStrings
      • resolvePluralKey

        public LocalizedString resolvePluralKey​(java.util.Locale locale,
                                                java.lang.String key,
                                                long amount)
        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 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.

        Overrides:
        resolvePluralKey in class WLocalizedStrings