Class I18n


  • public final class I18n
    extends Object
    This class provider methods for internationalization (I18n) services.
    • Method Detail

      • getBundle

        public static ResourceBundle getBundle​(Locale locale)
        Get a resource bundle for the given locale.
        Parameters:
        locale - the locale for which a resource bundle is desired
        Returns:
        an instance of I18nBundle
      • get

        public static String get​(String message)
        Return the localized translation of the given message, based on the current language.
        Parameters:
        message - the original message to be translated
        Returns:
        the localized message or the message itself if not found.
      • get

        public static String get​(String singular,
                                 String plural,
                                 int number)
        Similar to the get(String) but considers plural form based on the given number value.
         assertEquals("1 record selected.", I18n.get("{0} record selected.", "{0} records selected.", 1));
         assertEquals("5 records selected.", I18n.get("{0} record selected.", "{0} records selected.", 5));
         
        Parameters:
        singular - the singular form of the original message
        plural - the plural form of the original message
        number - the value to decide plurality
        Returns:
        the localized singular or plural message or the original message itself if not found.