Class TLcyLang
Internationalization
This class takes care of the internationalization capabilities of Lucy. Translations files are
searched by trying to find the file lucy/DefaultResources (e.g. lucy/DefaultResources_nl.properties)
The language is set (to Java) by using the -Duser.language=.. system property.
Lucy supports three languages:
- English (-Duser.language=en or any other unknown abbreviation)
- Dutch (-Duser.language=nl)
- French (-Duser.language=fr)
Other languages can simply be added by translating the DefaultResourceBundle to other languages.
To translate a string into the target language, use
TLcyLang.getString(aKey). Lucy uses the message in English as the key. This
means if no translations are available, Lucy is in English.
Adding bundles
When developing your own application which needs internationalization support, it is easiest to define your own resource bundles, so that you keep your own translations separate from the ones that ship with Lucy. You can do so be registering your additional bundles, for example like this:
ResourceBundle bundle = ResourceBundle.getBundle("myApp.TranslationBundle");
TLcyLang.registerResourceBundle("arbitraryID", bundle);
When requesting a translation, and the language is set to French for example, these files are checked, in this order:
- myApp/TranslationBundle_fr.properties
- lucy/DefaultResources_fr.properties
The file names are interpreted relative to the classpath.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final ResourceBundleReturns the default resource bundle.static final ResourceBundlegetResourceBundle(String aResourceBundleID) Returns the resource bundle associated with the given ID, ornullif there is none.static StringReturns the internationalized string corresponding to the specified key, by trying all registered resource bundles.static StringReturns the internationalized string corresponding to the specified key from the resource bundle that is associated with the specified identifier.static ILcdStringTranslatorReturns anILcdStringTranslatorthat translates strings similar togetString.static ILcdStringTranslatorgetStringTranslator(String aResourceBundleID) Returns anILcdStringTranslatorthat translates strings similar togetStringstatic booleanDeprecated.This method has been deprecated.static final ResourceBundleregisterResourceBundle(String aResourceBundleID, ResourceBundle aResourceBundle) Registers a resource bundle using a specified ID.static voidsetClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated.static final ResourceBundlesetDefaultResourceBundle(ResourceBundle aResourceBundle) Sets the default resource bundle to a specified resource bundlestatic final ResourceBundleunregisterResourceBundle(String aResourceBundleID) Unregisters the resource bundle that is associated with a specified ID.
-
Field Details
-
NEW_MAP
- See Also:
-
LASTCLICK
- See Also:
-
FILE
- See Also:
-
NEW
- See Also:
-
OPEN
- See Also:
-
LOAD
- See Also:
-
SAVE
- See Also:
-
SAVE_AS
- See Also:
-
CLOSE
- See Also:
-
DELETE
- See Also:
-
EXIT
- See Also:
-
OK
- See Also:
-
CANCEL
- See Also:
-
APPLY
- See Also:
-
MAP
- See Also:
-
PROJECTION
- See Also:
-
EDIT
- See Also:
-
COLORS
- See Also:
-
BACKGROUND
- See Also:
-
CONTROLS
- See Also:
-
EDIT_CURRENT
- See Also:
-
SHOW
- See Also:
-
WARNING
- See Also:
-
SHOW_ALL_ON
- See Also:
-
SHOW_SELECTED_ON
- See Also:
-
REMOVE_FROM
- See Also:
-
RESET
- See Also:
-
TOTE
- See Also:
-
MAX_CPU_USAGE
- See Also:
-
TIME_RANGE
- See Also:
-
TIME_FACTOR
- See Also:
-
UNCLASSIFIED
- See Also:
-
RESTRICTED
- See Also:
-
CONFIDENTIAL
- See Also:
-
SECRET
- See Also:
-
NOT_VALID_CLASSIFICATION
- See Also:
-
CAN_NOT_ADD_ELEMENT
- See Also:
-
SEC1
- See Also:
-
SEC2
- See Also:
-
SEC5
- See Also:
-
SEC10
- See Also:
-
SEC30
- See Also:
-
MIN1
- See Also:
-
MIN2
- See Also:
-
MIN5
- See Also:
-
MIN10
- See Also:
-
MIN30
- See Also:
-
PREVIEWER
- See Also:
-
PREVIEW_LAYER_NAME
- See Also:
-
MISSION_ID
- See Also:
-
ROLE
- See Also:
-
TARGET
- See Also:
-
UNIT
- See Also:
-
BASE
- See Also:
-
AIRCRAFT
- See Also:
-
NR_AIRCRAFT
- See Also:
-
SPEED
- See Also:
-
TOT
- See Also:
-
OBJ
- See Also:
-
PACKAGE
- See Also:
-
ANNEX
- See Also:
-
OVERVIEW
- See Also:
-
MAKE_OVERVIEW
- See Also:
-
INITIALIZING
- See Also:
-
APP_TITLE
- See Also:
-
DATA
- See Also:
-
AUTO_CENTER
- See Also:
-
AUTO_FIT
- See Also:
-
AUTO_RESIZE
- See Also:
-
AUTO_SELECT
- See Also:
-
UPDATE_POLYLINE
- See Also:
-
POINTLIST_ERROR
- See Also:
-
POINTLIST_ERROR_MESSAGE
- See Also:
-
-
Constructor Details
-
TLcyLang
public TLcyLang()
-
-
Method Details
-
getDefaultResourceBundle
Returns the default resource bundle.- Returns:
- the default resource bundle if it is loaded; null otherwise
- See Also:
-
setDefaultResourceBundle
Sets the default resource bundle to a specified resource bundle- Returns:
- the previous default resource bundle if it existed; null otherwise
- See Also:
-
isClassTraceOn
Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrueif tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setClassTraceOn
Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istruethen all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-
getStringTranslator
Returns anILcdStringTranslatorthat translates strings similar togetString.- Returns:
- An
ILcdStringTranslatorinstance. - See Also:
-
getStringTranslator
Returns anILcdStringTranslatorthat translates strings similar togetString- Parameters:
aResourceBundleID- the identifier for the resource bundle in which to search.- Returns:
- An
ILcdStringTranslatorinstance. - See Also:
-
getString
Returns the internationalized string corresponding to the specified key, by trying all registered resource bundles. More recently registered bundles take precedence over others. The default bundle is tried last. If no string was available for the specified key, the key itself is returned.- Parameters:
aKey- the key for which to get the internationalized string- Returns:
- the internationalized string if it is available in any of the registered resource bundles; the key itself otherwise
-
getString
Returns the internationalized string corresponding to the specified key from the resource bundle that is associated with the specified identifier. If no resource bundle is registered with this identifier, this method will try to find a string in the default resource bundle. If this also fails, the key itself is returned.- Parameters:
aResourceBundleID- the identifier for the resource bundle in which to searchaKey- the key for which to get the internationalized string- Returns:
- the internationalized string if it is available; the key itself otherwise
- See Also:
-
registerResourceBundle
public static final ResourceBundle registerResourceBundle(String aResourceBundleID, ResourceBundle aResourceBundle) Registers a resource bundle using a specified ID. This ID can be used later on to retrieve strings specifically from this resource bundle, using thegetString(String, String)method.- Parameters:
aResourceBundleID- the identifier for the resource bundleaResourceBundle- the resource bundle to register- Returns:
- the previous resource bundle that was registered using the specified key if there was one; null otherwise
- Throws:
IllegalArgumentException- if the key or the resource bundle is null- See Also:
-
unregisterResourceBundle
Unregisters the resource bundle that is associated with a specified ID.- Parameters:
aResourceBundleID- the identifier for the resource bundle to remove- Returns:
- the resource bundle that was registered using the specified key if there was one; null otherwise
- Throws:
IllegalArgumentException- if the key is null- See Also:
-
getResourceBundle
Returns the resource bundle associated with the given ID, ornullif there is none.- Parameters:
aResourceBundleID- the bundle ID- Returns:
- the resource bundle associated with the given ID, or
nullif there is none.
-