A single message within a Narrative, holding message text, optional substitution arguments and an optional translation code. Rendered to its final text (with translation and argument substitution applied) via toString().


Properties

PropertyReturnsDescription
argsObject[]The arguments substituted into this item's text placeholders when it is rendered.
textStringThe raw message text of this item, before argument substitution or translation.
transCodeStringThe translation code used to look up a translation for this item's text, if one was set.

Methods

text(String text, Object args)

Returns: NarrativeItem

Sets the text and substitution arguments on this item. The text should use "{}" as a placeholder for each argument, for example "Password must be {} characters long" with argument 8.

ParameterDescription
textthe message text, using "{}" as a placeholder for each argument
argsthe values to substitute into the placeholders, in order

transCode(String sourceType, String sourceId, String transCode)

Returns: NarrativeItem

Sets the transCode property, used to look up a translation for this message. Note that only the transCode value is stored by this method; the sourceType and sourceId parameters are accepted but not currently retained on the item.

ParameterDescription
sourceTypethe type of the object the translation is scoped to
sourceIdthe id of the object the translation is scoped to
transCodethe translation code to look up when rendering this item

getText()

Returns: String

The raw message text of this item, before argument substitution or translation.

getTransCode()

Returns: String

The translation code used to look up a translation for this item's text, if one was set.

getArgs()

Returns: Object[]

The arguments substituted into this item's text placeholders when it is rendered.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.