Interface Messages


public interface Messages

High level interface in to RiskScape's i18n subsystem.

  • Method Details

    • getDefaultLocale

      default Locale getDefaultLocale()
      Returns:
      the locale used by this Messages API if none is given. In most contexts it should be safe to rely on this instead of actually supplying one. In a web-based future, we will probably proxy the messages subsystem per request so that the locale is "correct".
    • getLabels

      MessageSource getLabels()
      Returns:
      the MessageSource used for getting object labels, e.g. nouns for things like projects, bookmarks etc
    • getHelp

      MessageSource getHelp()
      Returns:
      the MessageSource used for getting help text for various objects and concepts in RiskScape
    • getProblems

      MessageSource getProblems()
      Returns:
      the MessageSource used for getting problem descriptions, e.g. "Hey user, you did this wrong thing"
    • getDetailedMessage

      List<String> getDetailedMessage(MessageSource messageSource, Locale locale, Object owner, String... parts)

      Used for cases where the help is very detailed and can span several paragraphs. In cases like this the i18n message keys look like: [thing].description # brief [thing].description.1 # second paragraph [thing].description.2 # and so on

      Returns:
      all paragraphs matching the object/parts in a list
    • getMessage

      Optional<String> getMessage(MessageSource messageSource, Locale locale, Object owner, String... parts)
      Returns:
      a string containing the message from the given message source in the given locale, retrieved by building keys based on metadata in the owner object, e.g. class name, object's id field
    • getDetailedMessage

      default List<String> getDetailedMessage(MessageSource messageSource, Object owner, String... parts)
    • getMessage

      default Optional<String> getMessage(MessageSource messageSource, Object owner, String... parts)
    • getHelpMessage

      default Optional<String> getHelpMessage(Object owner, String... parts)

      Convenience form for getMessage(getHelp(), owner, parts), cos it's very commonly used

    • getDetailedHelpMessage

      default List<String> getDetailedHelpMessage(Object owner, String... parts)

      Convenience form for getDetailedMessage(getHelp(), owner, parts), cos it's very commonly used

    • newMessageSource

      MessageSource newMessageSource(String bundleName)

      Construct a MessageSource from the named resource bundle base name. i.e. newMessageSource("help") would create you the same MessagesSource as getHelp().

    • renderObject

      String renderObject(Object object, Locale locale)

      Turn a java object in to something that can be displayed as a simple, brief bit of text, serving as a plug-able, translatable-toString mechanism for for RiskScape

    • renderProblem

      RenderedProblem renderProblem(Problem problem, Locale locale)

      Turn a Problem in to a RenderedProblem - from there it can be transformed in to a string or otherwise. See TerminalCommand#renderProblem for an example.

    • renderProblem

      default RenderedProblem renderProblem(Problem problem)

      Convenience form for renderProblem(problem, Locale.getDefault())

    • renderProblem

      default RenderedProblem renderProblem(Throwable throwable)

      Convenience form for renderProblem(Problems.caught(throwable), Locale.getDefault())

    • renderProblem

      default RenderedProblem renderProblem(Throwable throwable, Locale locale)

      Convenience form for renderProblem(Problems.caught(throwable), locale)

    • addPluginResources

      void addPluginResources(Plugin plugin)

      Populate the i18n subsystem with plugin resources from the given plugin