Class I18nLoader


  • public class I18nLoader
    extends Object
    This class can load i18n message resources and keep them in memory for later reference. You can get a resource set with getI18n(), which will try to load the set at the first call. It uses I18nResourceFinder to find a matching properties file, in .properties format or .xml format. Note that a .properties file will be loaded as UTF-8.
    • Method Detail

      • getInstance

        public static I18nLoader getInstance()
        Returns the i18n loader.
        Returns:
        the i18n loader
      • getI18n

        public I18n getI18n​(String baseName,
                            Locale locale,
                            boolean honorifics,
                            Class<?> loadClass)
                     throws RuntimeException
        Returns the i18n message resource for the specified parameters. If the resource has not been loaded yet, it will be loaded now (.properties or .xml) and then saved in memory. Note that a .properties file will be loaded as UTF-8. For more details see I18nResourceFinder.
        Parameters:
        baseName - the base name
        locale - the preferred locale
        honorifics - true if the resource should use honorifics, false otherwise
        loadClass - the resource loading class or null
        Returns:
        the message resource
        Throws:
        RuntimeException - if no matching resource is found, or a matching resource can't be loaded
      • getI18n

        public I18n getI18n​(String baseName,
                            List<Locale> locales,
                            boolean honorifics,
                            Class<?> loadClass)
                     throws RuntimeException
        Returns the i18n message resource for the specified parameters. If the resource has not been loaded yet, it will be loaded now (.properties or .xml) and then saved in memory. Note that a .properties file will be loaded as UTF-8. For more details see I18nResourceFinder.
        Parameters:
        baseName - the base name
        locales - the preferred locales (at least one)
        honorifics - true if the resource should use honorifics, false otherwise
        loadClass - the resource loading class or null
        Returns:
        the message resource
        Throws:
        RuntimeException - if no matching resource is found, or a matching resource can't be loaded