Class WLocalizedStrings

java.lang.Object
eu.webtoolkit.jwt.WLocalizedStrings
Direct Known Subclasses:
WCombinedLocalizedStrings, WStdLocalizedStrings, WXmlLocalizedStrings

public abstract class WLocalizedStrings
extends java.lang.Object
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(String key), WApplication.setLocalizedStrings(WLocalizedStrings translator)
  • Constructor Summary

    Constructors
    Constructor Description
    WLocalizedStrings()  
  • Method Summary

    Modifier and Type Method Description
    static int evaluatePluralExpression​(java.lang.String expression, long n)
    Utility method to evaluate a plural expression.
    void hibernate()
    Purges memory resources, if possible.
    abstract LocalizedString resolveKey​(java.util.Locale locale, java.lang.String key)
    Resolves a key in the given locale.
    LocalizedString resolvePluralKey​(java.util.Locale locale, java.lang.String key, long amount)
    Resolves the plural form of a key in the given locale.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WLocalizedStrings

      public WLocalizedStrings()
  • Method Details

    • hibernate

      public void hibernate()
      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.

    • resolveKey

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

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

    • evaluatePluralExpression

      public static int evaluatePluralExpression​(java.lang.String expression, long n)
      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(Locale locale, String key, long amount)