Class I18n


  • public class I18n
    extends Object
    Internationalization class.
    • 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 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 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 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.