Interface Messages
High level interface in to RiskScape's i18n subsystem.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPluginResources
(Plugin plugin) Populate the i18n subsystem with plugin resources from the given plugindefault Locale
getDetailedHelpMessage
(Object owner, String... parts) Convenience form forgetDetailedMessage(getHelp(), owner, parts)
, cos it's very commonly usedgetDetailedMessage
(MessageSource messageSource, Object owner, String... parts) Same asgetDetailedMessage(MessageSource, Locale, Object, String...)
but using default localegetDetailedMessage
(MessageSource messageSource, Locale locale, Object owner, String... parts) Used for cases where the help is very detailed and can span several paragraphs.getHelp()
getHelpMessage
(Object owner, String... parts) Convenience form forgetMessage(getHelp(), owner, parts)
, cos it's very commonly usedgetMessage
(MessageSource messageSource, Object owner, String... parts) Same asgetMessage(MessageSource, Locale, Object, String...)
but using default localegetMessage
(MessageSource messageSource, Locale locale, Object owner, String... parts) newMessageSource
(String bundleName) Construct a MessageSource from the named resource bundle base name.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 RiskScapedefault RenderedProblem
renderProblem
(Throwable throwable) Convenience form forrenderProblem(Problems.caught(throwable), Locale.getDefault())
default RenderedProblem
renderProblem
(Throwable throwable, Locale locale) Convenience form forrenderProblem(Problems.caught(throwable), locale)
default RenderedProblem
renderProblem
(Problem problem) Convenience form forrenderProblem(problem, Locale.getDefault())
renderProblem
(Problem problem, Locale locale) Turn aProblem
in to aRenderedProblem
- from there it can be transformed in to a string or otherwise.
-
Method Details
-
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
Same as
getDetailedMessage(MessageSource, Locale, Object, String...)
but using default locale -
getMessage
Same as
getMessage(MessageSource, Locale, Object, String...)
but using default locale -
getHelpMessage
Convenience form for
getMessage(getHelp(), owner, parts)
, cos it's very commonly used -
getDetailedHelpMessage
Convenience form for
getDetailedMessage(getHelp(), owner, parts)
, cos it's very commonly used -
newMessageSource
Construct a MessageSource from the named resource bundle base name. i.e. newMessageSource("help") would create you the same MessagesSource as getHelp().
-
renderObject
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
Turn a
Problem
in to aRenderedProblem
- from there it can be transformed in to a string or otherwise. See TerminalCommand#renderProblem for an example. -
renderProblem
Convenience form for
renderProblem(problem, Locale.getDefault())
-
renderProblem
Convenience form for
renderProblem(Problems.caught(throwable), Locale.getDefault())
-
renderProblem
Convenience form for
renderProblem(Problems.caught(throwable), locale)
-
addPluginResources
Populate the i18n subsystem with plugin resources from the given plugin
-