dk.netarkivet.common.utils
Class I18n

java.lang.Object
  extended by dk.netarkivet.common.utils.I18n

public class I18n
extends java.lang.Object

Internationalization class.


Constructor Summary
I18n(java.lang.String translationsBundle)
          Make an internationalisation object with the given bundle.
 
Method Summary
 java.lang.String getString(java.util.Locale locale, java.lang.String label, java.lang.Object... args)
          Get a localized message for a given locale and label, and optionally arguments.
static java.lang.String getString(java.lang.String bundleName, java.util.Locale locale, java.lang.String label, java.lang.Object... args)
          Get a localized message for a given resource bundle, locale and label.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

I18n

public I18n(java.lang.String translationsBundle)
Make an internationalisation object with the given bundle.

Method Detail

getString

public java.lang.String getString(java.util.Locale locale,
                                  java.lang.String label,
                                  java.lang.Object... args)
Get a localized message for a given locale and label, and optionally arguments. E.g. I18N.getString(Locale.default, "job.unknown.id", 17) In contrast to ResourceBundle.getString(java.lang.String), this method is forgiving on errors

Parameters:
locale - The locale to get the string for
label - The label of the string in the resource bundle
args - Any args required for formatting the label
Returns:
The localised string, or the label if the string could not be found or the format is invalid or does not match the args.
Throws:
ArgumentNotValid - on null or empty local or label.

getString

public static java.lang.String getString(java.lang.String bundleName,
                                         java.util.Locale locale,
                                         java.lang.String label,
                                         java.lang.Object... args)
Get a localized message for a given resource bundle, locale and label. In contrast to ResourceBundle.getString(java.lang.String), this method is forgiving on errors I18n.getString("dk.netarkivet.common.Translations", Locale.default, "job.unknown.id", 17)

Parameters:
bundleName - The name of the resource bundle, fully qualified, but without the properties. See ResourceBundle.getBundle(String)
locale - The locale to get the string for
label - The label of the string in the resource bundle
args - Any args required for formatting the label
Returns:
The localised string, or the label if the string could not be found or the format is invalid or does not match the args.
Throws:
ArgumentNotValid - on null bundleName, locale or label.