Package dk.netarkivet.common.utils
Class I18n
- java.lang.Object
-
- dk.netarkivet.common.utils.I18n
-
public class I18n extends Object
Internationalization class.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
getString(String bundleName, Locale locale, String label, Object... args)
Get a localized message for a given resource bundle, locale and label.String
getString(Locale locale, String label, Object... args)
Get a localized message for a given locale and label, and optionally arguments.
-
-
-
Constructor Detail
-
I18n
public I18n(String translationsBundle)
Make an internationalisation object with the given bundle.
-
-
Method Detail
-
getString
public String getString(Locale locale, String label, 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 forlabel
- The label of the string in the resource bundleargs
- 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 String getString(String bundleName, Locale locale, String label, 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 errorsI18n.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. SeeResourceBundle.getBundle(String)
locale
- The locale to get the string forlabel
- The label of the string in the resource bundleargs
- 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.
-
-