Class I18nBase

java.lang.Object
cl.obcom.desktopfx.util.I18nBase

public abstract class I18nBase extends Object
Provides internationalization (i18n) services.
See Also:
  • Constructor Details

    • I18nBase

      protected I18nBase(Class<?> resClass, String resPrefix)
      Constructs a new I18nBase instance. The resource bundles must be located in the package of class resClass. The resource bundles are loaded using de default locale, and the class loader of class resClass. The names of the resource bundles must start with the specified resPrefix.
      Parameters:
      resClass - the class reference used to load resources.
      resPrefix - the prefix of all resource bundle names.
      Throws:
      NullPointerException - if an argument is null.
      See Also:
  • Method Details

    • onResourceNotFound

      protected void onResourceNotFound(String key)
      Called when a resource indexed by supplied key was not found.
      Parameters:
      key - the unique key of the required resource.
      Throws:
      NullPointerException - if key is null.
    • onSearchError

      protected void onSearchError(Throwable thrown, String key)
      Called when an error occurs searching for a resource with key.
      Parameters:
      thrown - describes the error that occurred.
      key - the unique key of the required resource.
      Throws:
      NullPointerException - if an argument is null.
    • onFormatError

      protected void onFormatError(Throwable thrown, String format, Object... args)
      Called when an error occurs formating an i18n message.
      Parameters:
      thrown - describes the error that occurred.
      format - a format string used to format the message.
      args - the arguments referenced by supplied format.
      Throws:
      NullPointerException - if an argument is null.
    • tr

      public final String tr(String message, Object... args)
      Translates and formats a message using supplied optional arguments.
      Parameters:
      message - the message that will be translated and formatted.
      args - the arguments referenced by the translated message.
      Returns:
      the translated and formatted i18n message.
      Throws:
      NullPointerException - if message is null.