TV-Browser 3.3.3 API

util.ui
Class Localizer

java.lang.Object
  extended by util.ui.Localizer
Direct Known Subclasses:
PooledLocalizer

public class Localizer
extends java.lang.Object

Does the localization of texts.

Each class that uses String that reach the user interface has its own Localizer. You can get a localized String by using one of the msg methods.

The msg methods have all the same pattern:
String msg(key, defaultValue, [args]);

Author:
Til Schneider, www.murfman.de

Field Summary
static java.lang.String I18N_ADD
           
static java.lang.String I18N_BACK
           
static java.lang.String I18N_CANCEL
           
static java.lang.String I18N_CHANNEL
           
static java.lang.String I18N_CHANNELS
           
static java.lang.String I18N_CLOSE
           
static java.lang.String I18N_DEFAULT
           
static java.lang.String I18N_DELETE
           
static java.lang.String I18N_DOWN
           
static java.lang.String I18N_EDIT
           
static java.lang.String I18N_ERROR
           
static java.lang.String I18N_FILE
           
static java.lang.String I18N_HELP
           
static java.lang.String I18N_INFO
           
static java.lang.String I18N_LEFT
           
static java.lang.String I18N_NEXT
           
static java.lang.String I18N_OK
           
static java.lang.String I18N_OPTIONS
           
static java.lang.String I18N_PICTURES
           
static java.lang.String I18N_PROGRAM
           
static java.lang.String I18N_PROGRAMS
           
static java.lang.String I18N_RIGHT
           
static java.lang.String I18N_SELECT
           
static java.lang.String I18N_SETTINGS
           
static java.lang.String I18N_STANDARD
           
static java.lang.String I18N_TODAY
           
static java.lang.String I18N_TOMORROW
           
static java.lang.String I18N_UP
           
static java.lang.String I18N_WARNING
           
static java.lang.String I18N_YESTERDAY
           
 
Constructor Summary
protected Localizer(java.lang.Class clazz)
          Creates a new instance of Localizer.
 
Method Summary
protected static void addLocalizerToCache(java.lang.Class clazz, Localizer localizer)
           
 java.lang.String ellipsis(java.lang.String someString)
          return the given String with an ellipsis appended
 java.lang.String ellipsisMsg(java.lang.String key, java.lang.String defaultMessage)
          get a localized message with an ellipsis as suffix
 java.lang.String ellipsisMsg(java.lang.String key, java.lang.String defaultMsg, java.lang.Object arg1)
          Gets a localized message ending with ellipsis suffix
static void emptyLocalizerCache()
          Clears the localizer cache.
 java.util.Locale[] getAllAvailableLocales()
          Scans all Language-Directories for different Versions of tvbrowser/tvbrowser.properties.
protected static Localizer getCachedLocalizerFor(java.lang.Class clazz)
           
static java.lang.String getEllipsisLocalization(java.lang.String key)
          get a standard localization with ellipsis as suffix
static java.util.Locale getLocaleForString(java.lang.String string)
          Get the Locale for a specific String.
static java.lang.String getLocalization(java.lang.String key)
          get a standard localization
static Localizer getLocalizerFor(java.lang.Class clazz)
          Gets the Localizer for the specified Class.
 boolean hasMessage(java.lang.String key)
          check if a given message key exists
protected  void initializeForClass(java.lang.Class clazz)
           
 java.lang.String msg(java.lang.String key, java.lang.String defaultMsg)
          Gets a localized message.
 java.lang.String msg(java.lang.String key, java.lang.String defaultMsg, boolean warn)
          Gets a localized message.
 java.lang.String msg(java.lang.String key, java.lang.String defaultMsg, java.lang.Object arg1)
          Gets a localized message.
 java.lang.String msg(java.lang.String key, java.lang.String defaultMsg, java.lang.Object[] args)
          Gets a localized message.
 java.lang.String msg(java.lang.String key, java.lang.String defaultMsg, java.lang.Object arg1, java.lang.Object arg2)
          Gets a localized message.
 java.lang.String msg(java.lang.String key, java.lang.String defaultMsg, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Gets a localized message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

I18N_OK

public static final java.lang.String I18N_OK
See Also:
Constant Field Values

I18N_CANCEL

public static final java.lang.String I18N_CANCEL
See Also:
Constant Field Values

I18N_CLOSE

public static final java.lang.String I18N_CLOSE
See Also:
Constant Field Values

I18N_DELETE

public static final java.lang.String I18N_DELETE
See Also:
Constant Field Values

I18N_EDIT

public static final java.lang.String I18N_EDIT
See Also:
Constant Field Values

I18N_PROGRAM

public static final java.lang.String I18N_PROGRAM
See Also:
Constant Field Values

I18N_PROGRAMS

public static final java.lang.String I18N_PROGRAMS
See Also:
Constant Field Values

I18N_CHANNEL

public static final java.lang.String I18N_CHANNEL
See Also:
Constant Field Values

I18N_CHANNELS

public static final java.lang.String I18N_CHANNELS
See Also:
Constant Field Values

I18N_HELP

public static final java.lang.String I18N_HELP
See Also:
Constant Field Values

I18N_FILE

public static final java.lang.String I18N_FILE
See Also:
Constant Field Values

I18N_ADD

public static final java.lang.String I18N_ADD
See Also:
Constant Field Values

I18N_SETTINGS

public static final java.lang.String I18N_SETTINGS
See Also:
Constant Field Values

I18N_UP

public static final java.lang.String I18N_UP
See Also:
Constant Field Values

I18N_DOWN

public static final java.lang.String I18N_DOWN
See Also:
Constant Field Values

I18N_LEFT

public static final java.lang.String I18N_LEFT
See Also:
Constant Field Values

I18N_RIGHT

public static final java.lang.String I18N_RIGHT
See Also:
Constant Field Values

I18N_BACK

public static final java.lang.String I18N_BACK
See Also:
Constant Field Values

I18N_NEXT

public static final java.lang.String I18N_NEXT
See Also:
Constant Field Values

I18N_PICTURES

public static final java.lang.String I18N_PICTURES
See Also:
Constant Field Values

I18N_OPTIONS

public static final java.lang.String I18N_OPTIONS
See Also:
Constant Field Values

I18N_SELECT

public static final java.lang.String I18N_SELECT
See Also:
Constant Field Values

I18N_ERROR

public static final java.lang.String I18N_ERROR
See Also:
Constant Field Values

I18N_DEFAULT

public static final java.lang.String I18N_DEFAULT
See Also:
Constant Field Values

I18N_STANDARD

public static final java.lang.String I18N_STANDARD
See Also:
Constant Field Values

I18N_YESTERDAY

public static final java.lang.String I18N_YESTERDAY
See Also:
Constant Field Values

I18N_TODAY

public static final java.lang.String I18N_TODAY
See Also:
Constant Field Values

I18N_TOMORROW

public static final java.lang.String I18N_TOMORROW
See Also:
Constant Field Values

I18N_INFO

public static final java.lang.String I18N_INFO
See Also:
Constant Field Values

I18N_WARNING

public static final java.lang.String I18N_WARNING
See Also:
Constant Field Values
Constructor Detail

Localizer

protected Localizer(java.lang.Class clazz)
Creates a new instance of Localizer.

Parameters:
clazz - The Class to create the Localizer for.
Method Detail

initializeForClass

protected void initializeForClass(java.lang.Class clazz)

getCachedLocalizerFor

protected static Localizer getCachedLocalizerFor(java.lang.Class clazz)

getLocalizerFor

public static Localizer getLocalizerFor(java.lang.Class clazz)
Gets the Localizer for the specified Class.

Parameters:
clazz - The Class to get the localizer for.
Returns:
the Localizer for the specified Class.

addLocalizerToCache

protected static void addLocalizerToCache(java.lang.Class clazz,
                                          Localizer localizer)

emptyLocalizerCache

public static void emptyLocalizerCache()
Clears the localizer cache.


msg

public java.lang.String msg(java.lang.String key,
                            java.lang.String defaultMsg,
                            java.lang.Object arg1)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message (English)
arg1 - The argument that should replace {0}.
Returns:
a localized message.

msg

public java.lang.String msg(java.lang.String key,
                            java.lang.String defaultMsg,
                            java.lang.Object arg1,
                            java.lang.Object arg2)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (English)
arg1 - The argument that should replace {0}.
arg2 - The argument that should replace {1}.
Returns:
a localized message.

msg

public java.lang.String msg(java.lang.String key,
                            java.lang.String defaultMsg,
                            java.lang.Object arg1,
                            java.lang.Object arg2,
                            java.lang.Object arg3)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (English)
arg1 - The argument that should replace {0}.
arg2 - The argument that should replace {1}.
arg3 - The argument that should replace {2}.
Returns:
a localized message.

msg

public java.lang.String msg(java.lang.String key,
                            java.lang.String defaultMsg,
                            java.lang.Object[] args)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (English)
args - The arguments that should replace the appropriate place holder. See MessageFormat for details.
Returns:
a localized message.

msg

public java.lang.String msg(java.lang.String key,
                            java.lang.String defaultMsg)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message (English)
Returns:
a localized message.

msg

public java.lang.String msg(java.lang.String key,
                            java.lang.String defaultMsg,
                            boolean warn)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message (English)
warn - If warnings should be logged if key is not found.
Returns:
a localized message.
Since:
2.5.1

getAllAvailableLocales

public java.util.Locale[] getAllAvailableLocales()
Scans all Language-Directories for different Versions of tvbrowser/tvbrowser.properties. This is faster than analyzing all Files

Returns:
all available Locales
Since:
2.3

getLocaleForString

public static java.util.Locale getLocaleForString(java.lang.String string)
Get the Locale for a specific String. The String is in this format: "lang_country_variant"

Parameters:
string - String with Locale
Returns:
Locale

getLocalization

public static java.lang.String getLocalization(java.lang.String key)
get a standard localization

Parameters:
key - one of the constant values defined in the Localizer class
Returns:
localized message for key

getEllipsisLocalization

public static java.lang.String getEllipsisLocalization(java.lang.String key)
get a standard localization with ellipsis as suffix

Parameters:
key - one of the constant values defined in the Localizer class
Returns:
localized message for key

ellipsisMsg

public java.lang.String ellipsisMsg(java.lang.String key,
                                    java.lang.String defaultMessage)
get a localized message with an ellipsis as suffix

Parameters:
key - localization key
defaultMessage - default (English) message
Returns:
localized message
Since:
3.0

ellipsisMsg

public java.lang.String ellipsisMsg(java.lang.String key,
                                    java.lang.String defaultMsg,
                                    java.lang.Object arg1)
Gets a localized message ending with ellipsis suffix

Parameters:
key - The key of the message.
defaultMsg - The default message (English)
arg1 - The argument that should replace {0}.
Returns:
a localized message.

hasMessage

public boolean hasMessage(java.lang.String key)
check if a given message key exists

Parameters:
key -
Returns:
true if the given key exists
Since:
3.0

ellipsis

public java.lang.String ellipsis(java.lang.String someString)
return the given String with an ellipsis appended

Parameters:
someString -
Returns:
ellipsis appended String or null
Since:
3.0

TV-Browser 3.3.3 API

TV-Browser 3.3.3, Copyright (C) 2004-2008 TV-Browser Team (dev@tvbrowser.org)