Class TLcyLang

java.lang.Object
com.luciad.lucy.util.language.TLcyLang

public class TLcyLang extends Object

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: