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
| Property | Returns | Description |
|---|---|---|
| args | Object[] | The arguments substituted into this item's text placeholders when it is rendered. |
| text | String | The raw message text of this item, before argument substitution or translation. |
| transCode | String | The 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.
| Parameter | Description |
|---|---|
text | the message text, using "{}" as a placeholder for each argument |
args | the 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.
| Parameter | Description |
|---|---|
sourceType | the type of the object the translation is scoped to |
sourceId | the id of the object the translation is scoped to |
transCode | the 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.