adapforms.runtime.i18n
Class Localization

java.lang.Object
  extended by adapforms.runtime.i18n.Localization

public class Localization
extends java.lang.Object

Provides a localization mechanism for adaptive forms. Contains a Locale and a mapping from keys and phrases onto their translated textual counterpart (both are optional).

You may want to use one of the pre-configured localizations supplied by LocalizationFactory.

The Locale is used to localize calendars and perform similar standard translations etc.

The optional translation mapping is used in two ways:
- When printing labels to the user interface, they are first attempted translated through this mapping. If no matching translation is found, the label is printed in it's original form.
- When printing framework messages or problem messages to the user interface, they are attempted translated. The default translation used for this (and thus a basis for translation), can be found in DefaultTranslation.

Author:
Henrik Gammelmark, geemark@cs.au.dk

Constructor Summary
Localization(java.util.Locale locale, java.util.Properties translations)
          Create a new localization.
 
Method Summary
 java.util.Locale getLocale()
          The Locale to use for basic system translations and customization.
 java.util.Properties getTranslations()
          Get the translation mapping.
 java.lang.String translate(java.lang.String text)
          Perform simple translation from one text to another.
 java.lang.String translateKey(java.lang.String key, java.lang.String... args)
          Given a translation key, possibly containing placeholders, translate it and insert the given values at the placeholder positions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Localization

public Localization(java.util.Locale locale,
                    java.util.Properties translations)
Create a new localization.

Parameters:
locale - Locale to use, or null to use default.
translations - Translation mapping, or null to use default.
Method Detail

getLocale

public java.util.Locale getLocale()
The Locale to use for basic system translations and customization.


getTranslations

public java.util.Properties getTranslations()
Get the translation mapping. Returns null if none specified.


translateKey

public java.lang.String translateKey(java.lang.String key,
                                     java.lang.String... args)
Given a translation key, possibly containing placeholders, translate it and insert the given values at the placeholder positions.

Parameters:
key - Translation key used for looking up the translation string.
args - Values to substitude for the placeholders
Returns:
Translated string

translate

public java.lang.String translate(java.lang.String text)
Perform simple translation from one text to another. If no translation is found, the text is returned unaltered.

Parameters:
text - Message to translate