All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class multilizer.TextDictionary

java.lang.Object
   |
   +----multilizer.Dictionary
           |
           +----multilizer.BundleDictionary
                   |
                   +----multilizer.FileDictionary
                           |
                           +----multilizer.TextDictionary

public class TextDictionary
extends FileDictionary
A dictionary component that gets translation data from Unicode (UTF-8 ort UTF-16) files or streams.

Using Files

Set the FileName property to contain the name of the language file. Set the TranslatioFileName property to contain the name of the translation file.

Language File format
Translation File format

An example:

 TextDictionary dictionary = new TextDictionary();
 dictionary.setFileName("dictionary.languages");
 dictionary.setTranslationFileName("dictionary.translations");
 dictionary.open();
 
You can also set the dictionary read data from streams. Write the getLanguageStream and getTranslationStream events. Create the streams in the events. The streams must contain the same Unicode data as the text files.

Language File format
Translation File format

An example:

 public class SampleFrame implements TranslationStreamListener
 ...
 TextDictionary dictionary = new TextDictionary();
 dictionary.addLanguageStreamListener(new LanguageStreamListener()
 {
   public void getLanguageStream(StreamEventObject e) throws Exception
   {
     dictionary_getLanguageStream(e);
   }
 });
 dictionary.addTranslationStreamListener(new TranslationStreamListener()
 {
   public void getTranslationStream(StreamEventObject e) throws Exception
   {
     dictionary_getTranslationStream(e);
   }
 });
 dictionary.open();
 ...
 void dictionary_getLanguageStream(StreamEventObject e) throws Exception
 {
   e.setStream(new FileInputStream(e.getFileName()));
 }
 void dictionary_getTranslationStream(StreamEventObject e) throws Exception
 {
   e.setStream(new FileInputStream(e.getFileName()));
 }
 

Using File Bundle

Set the FileName property to contain the name of the bundle name. The bundle contains one language file ("<name>.languages"), one translation file for each supported language ("<name>_<locale>.translations"), and an optional locale file ("<name>.locales").

Language File format
Translation File format

An example that uses "dictionary.languages" as a language file, "dictionary_en.translations" and "dictionary_fi.translations" as the translations files (supposing that the dictionary contains two languages, English and Finnish):

 TextDictionary dictionary = new TextDictionary();
 dictionary.setFileName("dictionary");
 dictionary.open();
 

You can also set the dictionary read the dictionary data from streams using the events desribed above.

See Also:
BinaryDictionary

Variable Index

 o TRANSLATION_FILE_EXTENSION

Constructor Index

 o TextDictionary()

Method Index

 o getConvert()
Gets the conversion state.
 o getLanguageStream()
 o getTranslationFileName()
Gets the translation file name.
 o loadTranslation(Vector, String)
Loads the translation data from the file to the array.
 o setConvert(boolean)
Enables or disables the string conversion.
 o setTranslationFileName(String)
Sets the translation file name.

Variables

 o TRANSLATION_FILE_EXTENSION
 public static final String TRANSLATION_FILE_EXTENSION

Constructors

 o TextDictionary
 public TextDictionary()

Methods

 o getLanguageStream
 protected UnicodeInputStream getLanguageStream() throws Exception
Throws: Exception
An exception
Overrides:
getLanguageStream in class BundleDictionary
 o setTranslationFileName
 public void setTranslationFileName(String value)
Sets the translation file name. This is only used when the file bundle is not used.

See Also:
getTranslationFileName, getFileUsage
 o getTranslationFileName
 public String getTranslationFileName()
Gets the translation file name.

See Also:
setTranslationFileName
 o setConvert
 public void setConvert(boolean value)
Enables or disables the string conversion. If this is true, "#T" is converted to a tab (\t) character, "#L" is converted to a line feed (\n) character, "#C" is converted to a carriage return (\r) character, and "##" is converted to a # character,

See Also:
getConvert
 o getConvert
 public boolean getConvert()
Gets the conversion state.

See Also:
setConvert
 o loadTranslation
 protected void loadTranslation(Vector translations,
                                String fileName)
Loads the translation data from the file to the array.

Overrides:
loadTranslation in class FileDictionary

All Packages  Class Hierarchy  This Package  Previous  Next  Index