com.retek.commons.gui.util
Class TranslatorManager

java.lang.Object
  extended bycom.retek.commons.gui.util.TranslatorManager
Direct Known Subclasses:
LanguageTranslator, MessageTranslator, MnemonicTranslator

public class TranslatorManager
extends java.lang.Object

This class encapsulates a property bundle and is used as the superclass of managers that handler translations (LanguageManager, MessageManager and Mnemonic Manager).

This class was designed so that the {filename}.properties file could contain actual english text directly with spaces, allowing programmers to use english labels during coding but automatically have these labels translated. It avoids the usage of tags and executes quickly for the en and en_US locale as the properties will be empty.

The currently assigned locale is used to determine the sequence of filenames used for language translation. For example, if the locale is set to the English language and United States as a country, and "lang" is passed in as a filename parameter, the language tool will attempt to load the following: lang_en.properties, and then lang_en_US.properties, and finally lang_en_US_??.properties where ?? is the variant in Locale. Keys in latter files override the keys in earlier files.

Retek Inc. Copyright (c) 2002


Field Summary
protected static java.lang.String EMPTY
           
 
Constructor Summary
TranslatorManager()
          Returns new TranslatorManager object.
TranslatorManager(java.util.Locale locale, java.lang.String filename)
          Returns new LanguageManager object.
TranslatorManager(java.lang.String filename)
          Returns new TranslatorManager object.
 
Method Summary
protected  RPropertyBundle getBundle()
          Retrieves the bundle being used by this manager.
 java.util.Locale getLocale()
          Retrieves the locale information assigned to this language tool.
 boolean setBundle(java.lang.String filename)
          Uses the filename to create a property bundle to retrieve translations from.
 void setLocale(java.util.Locale locale)
          Sets the locale of the language tool.
 void setLocale(java.lang.String language, java.lang.String country, java.lang.String variant)
          Sets the locale of the language tool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

protected static final java.lang.String EMPTY
Constructor Detail

TranslatorManager

public TranslatorManager()
Returns new TranslatorManager object.


TranslatorManager

public TranslatorManager(java.lang.String filename)
                  throws UiBundleException
Returns new TranslatorManager object.

Parameters:
filename - The filename of the properties file to load.
Throws:
UiBusinessException - Thrown if the method fails to load the property file.
UiBundleException

TranslatorManager

public TranslatorManager(java.util.Locale locale,
                         java.lang.String filename)
                  throws UiBundleException
Returns new LanguageManager object.

Parameters:
locale - The Locale to load the properties file for.
filename - The filename of the properties file to load.
Throws:
UiBusinessException - Thrown if the method fails to load the property file.
UiBundleException
Method Detail

getBundle

protected RPropertyBundle getBundle()
Retrieves the bundle being used by this manager. This method is protected in order to only expose it to child classes.

Returns:
The current properties file bundle.

setBundle

public boolean setBundle(java.lang.String filename)
                  throws UiBundleException
Uses the filename to create a property bundle to retrieve translations from. This method will attempt to load the filename for a particular Locale in a sequence from most generic to most specific. It loads the language, then the country file, then the variant file.

Parameters:
filename - The filename of a properties file.
Returns:
True if the bundle was successfully loaded, false if it was not.
Throws:
UiBusinessException - Thrown if a file error occurs in the underlying bundle.
UiBundleException

setLocale

public void setLocale(java.lang.String language,
                      java.lang.String country,
                      java.lang.String variant)
Sets the locale of the language tool. If this is set prior to the attempt to load a particular file, the language tool will use it to expand and determine filename.

Parameters:
language - Lowercase two-letter ISO-639 code.
country - Uppercase two-letter ISO-3166 code.
variant - Vendor specific code.

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale of the language tool. The locale will determine the series of filenames that are attempting during the loading of language files. If a bundle is assigned to the class directly, the locale will be overridden.

Parameters:
locale - A locale object containg the locale information.

getLocale

public java.util.Locale getLocale()
Retrieves the locale information assigned to this language tool.

Returns:
A Locale object containing the locale information.


Copyright © 2004 Retek Inc. All Rights Reserved. - Generated at Fri, 10/22/2004 07:28