soc.util
Class I18n

java.lang.Object
  extended by soc.util.I18n

public abstract class I18n
extends java.lang.Object

Common helper methods for I18N.

I18N localization was added in v2.0.00; network messages sending localized text should check the remote receiver's version against SOCStringManager.VERSION_FOR_I18N.

Since:
2.0.00
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
SOCStringManager

Field Summary
static java.lang.String PROP_JSETTLERS_LOCALE
          Property jsettlers.locale to specify the locale, overriding the default from Locale.getDefault().toString().
 
Constructor Summary
I18n()
           
 
Method Summary
static java.lang.String listItems(java.util.List<? extends java.lang.Object> items, SOCStringManager strings)
          Build a string with the contents of this list, such as "x, y, and z".
static java.util.Locale parseLocale(java.lang.String loc)
          Parse and construct a Locale for this locale string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_JSETTLERS_LOCALE

public static final java.lang.String PROP_JSETTLERS_LOCALE
Property jsettlers.locale to specify the locale, overriding the default from Locale.getDefault().toString().

See Also:
Constant Field Values
Constructor Detail

I18n

public I18n()
Method Detail

parseLocale

public static final java.util.Locale parseLocale(java.lang.String loc)
                                          throws java.lang.IllegalArgumentException
Parse and construct a Locale for this locale string.

Parameters:
loc - Locale string, such as "en_US" from Locale.toString()
Returns:
A Locale object, or if 0-length, Locale.getDefault().
Throws:
java.lang.IllegalArgumentException - if no locale can be parsed or found

listItems

public static final java.lang.String listItems(java.util.List<? extends java.lang.Object> items,
                                               SOCStringManager strings)
                                        throws java.lang.IllegalArgumentException
Build a string with the contents of this list, such as "x, y, and z".

This method and its formatting strings (i18n.listitems.*) may need refinement as more languages are supported.

Parameters:
items - Each item's toString() will be placed in the list
strings - StringManager to retrieve localized formatting between items
Returns:
A string nicely listing the items, with a form such as:
  • nothing
  • x
  • x and y
  • x, y, and z
  • x, y, z, and w
Throws:
java.lang.IllegalArgumentException - if items is null, or strings is null