Class I18n


  • public class I18n
    extends Object
    This class defines a set of i18n message resources. An instance of this class is normally obtained from I18nLoader. 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.

    When you have an instance, you can call get() to get message strings.

    • Constructor Detail

      • I18n

        public I18n​(String baseName,
                    List<Locale> locales,
                    boolean honorifics,
                    Class<?> loadClass)
             throws RuntimeException
        Constructs a new instance. It finds a matching resource (.properties or .xml) for the specified parameters and tries to load it. 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
        honorifics - true if the resource should use honorifics, false otherwise
        loadClass - the resource loading class or null
        Throws:
        RuntimeException - if no matching resource is found, or a matching resource can't be loaded
    • Method Detail

      • get

        public String get​(String code)
        Returns the message string with the specified code.
        Parameters:
        code - the message code
        Returns:
        the message string