Klasse LocalizationTool

java.lang.Object
org.apache.turbine.services.localization.LocalizationTool
Alle implementierten Schnittstellen:
ApplicationTool

public class LocalizationTool extends Object implements ApplicationTool
A pull tool which provides lookups for localized text by delegating to the configured Fulcrum LocalizationService.
Autor:
Eric Pugh, Daniel Rall, Jon Stevens
  • Felddetails

    • locale

      protected Locale locale
      The language and country information parsed from the request's Accept-Language header. Reset on each request.
  • Konstruktordetails

    • LocalizationTool

      Creates a new instance. Used by PullService.
  • Methodendetails

    • get

      public String get(String key)

      Performs text lookups for localization.

      Assuming there is a instance of this class with a HTTP request set in your template's context named l10n, the VTL $l10n.HELLO would render to hello for English requests and hola in Spanish (depending on the value of the HTTP request's Accept-Language header).

      Parameter:
      key - The identifier for the localized text to retrieve.
      Gibt zurück:
      The localized text.
    • getLocale

      public Locale getLocale()
      Gets the current locale.
      Gibt zurück:
      The locale currently in use.
    • getBundleName

      protected String getBundleName(Object data)
      The return value of this method is used to set the name of the bundle used by this tool. Useful as a hook for using a different bundle than specified in your LocalizationService configuration.
      Parameter:
      data - The inputs passed from init(Object). (ignored by this implementation).
      Gibt zurück:
      the name of the bundle to use
    • format

      public String format(String key, Object... args)
      Formats a localized value using the provided objects.
      Parameter:
      key - The identifier for the localized text to retrieve,
      args - The objects to use as {0}, {1}, etc. when formatting the localized text.
      Gibt zurück:
      Formatted localized text.
    • init

      public void init(Object data)
      Sets the request to get the Accept-Language header from (reset on each request).
      Angegeben von:
      init in Schnittstelle ApplicationTool
      Parameter:
      data - initialization data
    • refresh

      public void refresh()
      No-op.
      Angegeben von:
      refresh in Schnittstelle ApplicationTool