net.sourceforge.worldsaver.util
Class Localizer

java.lang.Object
  |
  +--net.sourceforge.worldsaver.util.Localizer

public class Localizer
extends java.lang.Object

This is a wrapper class that handles several localized language files. To use this, you must have some language files somewhere. If you have a package com.microsoft.stupid you could have a dir called lang there with a language file `deutsch'. Then you would call new Localizer() or setLang() with ("/com/microsoft/stupid/lang/",Locale.GERMAN) to initialize this class.

Version:
15 Mar 2000
Author:
Andreas Schmitz

Constructor Summary
Localizer(java.util.Locale loc, java.lang.String path)
          Constructs a new Localizer.
 
Method Summary
 java.lang.String get(java.lang.String key)
          Returns the localized String mapping the key.
 java.lang.String get(java.lang.String key, java.lang.String param1)
          Returns the localized String mapping the key.
 java.lang.String get(java.lang.String key, java.lang.String param1, java.lang.String param2)
          Returns the localized String mapping the key.
 java.lang.String get(java.lang.String key, java.lang.String param1, java.lang.String param2, java.lang.String param3)
          Returns the localized String mapping the key.
 boolean setLang(java.util.Locale loc, java.lang.String path)
          Sets the new language for this Localizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Localizer

public Localizer(java.util.Locale loc,
                 java.lang.String path)
          throws java.io.IOException
Constructs a new Localizer. Throws an IOException if the language file had not been found.
Parameters:
loc - the locale which language should be used
path - the path to the new language file
Throws:
java.io.IOException - if no language file for loc had been found
Method Detail

setLang

public boolean setLang(java.util.Locale loc,
                       java.lang.String path)
Sets the new language for this Localizer. Returns whether the new language exists or not.
Parameters:
loc - the locale which language should be used
path - the path to the new language file
Returns:
true if the new language had set, otherwise false.

get

public java.lang.String get(java.lang.String key)
Returns the localized String mapping the key.
Parameters:
key - the key
Returns:
the String

get

public java.lang.String get(java.lang.String key,
                            java.lang.String param1)
Returns the localized String mapping the key. The second parameter replaces the xxx in the localized String.
Parameters:
key - the key
param1 - the replacement for xxx
Returns:
the String

get

public java.lang.String get(java.lang.String key,
                            java.lang.String param1,
                            java.lang.String param2)
Returns the localized String mapping the key. The second parameter replaces the xxx in the localized String, the third replaces the yyy.
Parameters:
key - the key
param1 - the replacement for xxx
param2 - the replacement for yyy
Returns:
the String

get

public java.lang.String get(java.lang.String key,
                            java.lang.String param1,
                            java.lang.String param2,
                            java.lang.String param3)
Returns the localized String mapping the key. The second parameter replaces the xxx in the localized String, the third replaces the yyy and the fourth the zzz.
Parameters:
key - the key
param1 - the replacement for xxx
param2 - the replacement for yyy
param3 - the replacement for zzz
Returns:
the String