data
Class Translator

java.lang.Object
  extended by data.Translator

public class Translator
extends java.lang.Object

This class is the main construct for serving strings to requesting classes depending on the language setting. It reads all language info from the persistance layer and provides atoms of it on request.


Field Summary
private  java.lang.String dictionary
           
private  org.dom4j.Document document
           
private  java.lang.String language
           
private  java.lang.String languageName
           
private  Launcher launcher
           
private  org.dom4j.Element root
           
private  java.lang.String worddatabase
           
 
Constructor Summary
Translator(Launcher launcher)
          The constructor creates a document object containing the XML content of the language file.
 
Method Summary
 java.lang.String getDictionary()
           
 java.lang.String getLanguage()
           
 java.lang.String getLanguageName()
           
 java.util.Vector<java.lang.String> getLanguages()
          This method gets all languages from the language file.
 java.lang.String getTranslation(java.lang.String id)
          Used to get a String in the current language.
 java.lang.String getWorddatabase()
           
private  void loadDictionary()
           
private  void loadWorddatabase()
           
 void setLanguage(java.lang.String languageName)
          Set the new language to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

language

private java.lang.String language

languageName

private java.lang.String languageName

dictionary

private java.lang.String dictionary

worddatabase

private java.lang.String worddatabase

launcher

private Launcher launcher

document

private org.dom4j.Document document

root

private org.dom4j.Element root
Constructor Detail

Translator

public Translator(Launcher launcher)
The constructor creates a document object containing the XML content of the language file. It also sets the default language.

Parameters:
Launcher - launcher - the parent class, used to reference the GUI objects
Method Detail

getLanguages

public java.util.Vector<java.lang.String> getLanguages()
This method gets all languages from the language file.

Returns:
Vector languages The languages

getTranslation

public java.lang.String getTranslation(java.lang.String id)
Used to get a String in the current language. This is the method called by all other classes to receive a certain language-specific string.

Parameters:
String - id The id of the component the String belongs to. The id is specified by the keys of the language xml file.
Returns:
The String in the current language.

setLanguage

public void setLanguage(java.lang.String languageName)
Set the new language to use. Classes use this method to request switching the language context.

Parameters:
languageName - The new language.

getLanguage

public java.lang.String getLanguage()

getLanguageName

public java.lang.String getLanguageName()

getDictionary

public java.lang.String getDictionary()

loadDictionary

private void loadDictionary()

getWorddatabase

public java.lang.String getWorddatabase()

loadWorddatabase

private void loadWorddatabase()