net.sf.freecol.client.gui.i18n
Class Messages

java.lang.Object
  extended by net.sf.freecol.client.gui.i18n.Messages

public class Messages
extends java.lang.Object

Represents a collection of messages in a particular locale.

This class is NOT thread-safe. (CO: I cannot find any place that really has a problem)

Messages are put in the file "FreeColMessages.properties". This file is presently located in the same directory as the source file of this class.


Field Summary
static java.lang.String FILE_PREFIX
           
static java.lang.String FILE_SUFFIX
           
static java.lang.String STRINGS_DIRECTORY
           
 
Constructor Summary
Messages()
           
 
Method Summary
static boolean containsKey(java.lang.String key)
          Returns true if the message bundle contains the given key.
static java.lang.String getDescription(FreeColObject object)
          Returns the localized description of a FreeColObject.
static java.io.File getI18nDirectory()
          Returns the directory containing language property files.
static java.lang.String getKey(java.lang.String preferredKey, java.lang.String defaultKey)
          Returns the preferred key if it is contained in the message bundle and the default key otherwise.
static java.lang.String getLabel(ColonyTile colonyTile)
          Returns a description of the tile, with the name of the tile and any improvements made to it (road/plow).
static java.lang.String getLabel(Goods goods)
          Returns a description of the goods.
static java.lang.String getLabel(GoodsType type, int amount)
          Returns a description of the goods.
static java.lang.String getLabel(Tile tile)
          Returns a description of the Tile, with the name of the tile and any improvements on it (road/plow/etc) from TileItemContainer.
static java.lang.String getLabel(TileItemContainer tic)
          Returns a description of the tile, with the name of the tile and any improvements made to it (road/plow)
static java.lang.String getLabel(Unit unit)
          Returns the name of a unit in a human readable format.
static java.lang.String getLabel(UnitType someType, Unit.Role someRole)
          Returns the name of a unit in a human readable format.
static java.lang.String getLocationName(Building building)
          Returns the location name of the given Building.
static java.lang.String getLocationName(ColonyTile colonyTile)
          Returns the (non-unique) name of the given ColonyTile.
static java.lang.String getLocationName(Location location)
          Describe getLocationName method here.
static java.lang.String getLocationName(Tile tile)
          Returns the location name of the given Tile.
static java.lang.String getLocationName(Unit unit)
          Returns a name for this unit, as a location.
static java.lang.String getName(Feature object)
          Returns the localized name of a Feature.
static java.lang.String getName(FoundingFather.FoundingFatherType type)
          Return the localized type of the given FoundingFather.
static java.lang.String getName(FreeColGameObjectType object)
          Returns the localized name of a FreeColGameObjectType.
static java.lang.String getName(Tile tile)
          Gets the name of a Tile, or shows "unexplored" if not explored by player.
static java.lang.String getName(Typed object)
          Returns the localized name of a FreeColGameObject implementing the Typed interface.
static java.lang.String getNationAsString(Player player)
          Returns the nation of the given player as a String.
static void loadResources(java.io.File resourceFile)
          Calling this method can be used to replace the messages used currently with a new bundle.
static java.lang.String message(java.lang.String messageId, java.lang.String... data)
          Finds the message with a particular ID in the default locale and performs string replacements.
static void setMessageBundle(java.util.Locale locale)
          Set the resource bundle for the given locale
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRINGS_DIRECTORY

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

FILE_PREFIX

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

FILE_SUFFIX

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

Messages

public Messages()
Method Detail

setMessageBundle

public static void setMessageBundle(java.util.Locale locale)
Set the resource bundle for the given locale

Parameters:
locale -

getI18nDirectory

public static java.io.File getI18nDirectory()
Returns the directory containing language property files.

Returns:
a File value

message

public static java.lang.String message(java.lang.String messageId,
                                       java.lang.String... data)
Finds the message with a particular ID in the default locale and performs string replacements.

Parameters:
messageId - The key of the message to find
data - consists of pairs of strings, each time the first of the pair is replaced by the second in the messages.

containsKey

public static boolean containsKey(java.lang.String key)
Returns true if the message bundle contains the given key.

Parameters:
key - a String value
Returns:
a boolean value

getKey

public static java.lang.String getKey(java.lang.String preferredKey,
                                      java.lang.String defaultKey)
Returns the preferred key if it is contained in the message bundle and the default key otherwise. This should be used to select the most specific message key available.

Parameters:
preferredKey - a String value
defaultKey - a String value
Returns:
a String value

loadResources

public static void loadResources(java.io.File resourceFile)
Calling this method can be used to replace the messages used currently with a new bundle. This is used only in the debugging of FreeCol.

Parameters:
resourceFile -

getName

public static final java.lang.String getName(FreeColGameObjectType object)
Returns the localized name of a FreeColGameObjectType.

Parameters:
object - a FreeColGameObjectType value
Returns:
a String value

getName

public static final java.lang.String getName(Typed object)
Returns the localized name of a FreeColGameObject implementing the Typed interface.

Parameters:
object - a Typed value
Returns:
a String value

getName

public static final java.lang.String getName(Feature object)
Returns the localized name of a Feature.

Parameters:
object - a Feature value
Returns:
a String value

getName

public static java.lang.String getName(Tile tile)
Gets the name of a Tile, or shows "unexplored" if not explored by player.

Parameters:
tile - a Tile value
Returns:
The name as a String.

getName

public static java.lang.String getName(FoundingFather.FoundingFatherType type)
Return the localized type of the given FoundingFather.

Parameters:
type - an int value
Returns:
a String value

getDescription

public static final java.lang.String getDescription(FreeColObject object)
Returns the localized description of a FreeColObject.

Parameters:
object - a FreeColObject value
Returns:
a String value

getLabel

public static java.lang.String getLabel(Unit unit)
Returns the name of a unit in a human readable format. The return value can be used when communicating with the user.

Parameters:
unit - an Unit value
Returns:
The given unit type as a String

getLabel

public static java.lang.String getLabel(UnitType someType,
                                        Unit.Role someRole)
Returns the name of a unit in a human readable format. The return value can be used when communicating with the user.

Parameters:
someType - an UnitType value
someRole - a Role value
Returns:
The given unit type as a String

getLabel

public static java.lang.String getLabel(Tile tile)
Returns a description of the Tile, with the name of the tile and any improvements on it (road/plow/etc) from TileItemContainer.

Parameters:
tile - a Tile value
Returns:
The description label for this tile

getLabel

public static java.lang.String getLabel(ColonyTile colonyTile)
Returns a description of the tile, with the name of the tile and any improvements made to it (road/plow).

Parameters:
colonyTile - a ColonyTile value
Returns:
The description label for this tile

getLabel

public static java.lang.String getLabel(Goods goods)
Returns a description of the goods.

Parameters:
goods - a Goods value
Returns:
The description label for this tile

getLabel

public static java.lang.String getLabel(GoodsType type,
                                        int amount)
Returns a description of the goods.

Parameters:
type - a GoodsType value
amount - an int value
Returns:
The description label for this tile

getLabel

public static java.lang.String getLabel(TileItemContainer tic)
Returns a description of the tile, with the name of the tile and any improvements made to it (road/plow)

Parameters:
tic - a TileItemContainer value
Returns:
The description label for this tile

getNationAsString

public static java.lang.String getNationAsString(Player player)
Returns the nation of the given player as a String.

Parameters:
player - a Player value
Returns:
The nation of this player as a String.

getLocationName

public static java.lang.String getLocationName(Tile tile)
Returns the location name of the given Tile.

Returns:
The name of this location.

getLocationName

public static java.lang.String getLocationName(Building building)
Returns the location name of the given Building.

Parameters:
building - a Building value
Returns:
The name of this location.

getLocationName

public static java.lang.String getLocationName(ColonyTile colonyTile)
Returns the (non-unique) name of the given ColonyTile.

Parameters:
colonyTile - a ColonyTile value
Returns:
The name of this ColonyTile.

getLocationName

public static java.lang.String getLocationName(Unit unit)
Returns a name for this unit, as a location.

Returns:
A name for this unit, as a location.

getLocationName

public static java.lang.String getLocationName(Location location)
Describe getLocationName method here.

Parameters:
location - a Location value
Returns:
a String value