Text Formatter
Creates a string from a pattern by replacing placeholders with concrete values.
API
The text
formatter takes as a first argument a string that contains placeholders (typically a text from i18n resource bundle).
The second argument is an array of values that will be put inside the placeholders.
format.text(pattern, values)
Param | Type | Required | Description | Since |
---|---|---|---|---|
pattern | string | Yes | A string that contains placeholders. For example "Some text {0}". For detailed description about possible patterns and how to escape them read theformatMessage documentation. | 1.86 |
values | any[] | Yes | Values, that will be put in the placeholders. The first value of the array will be put in placeholder "{0}", the second value will be put in placeholder "{1}" and so on... | 1.86 |
Returns | ||||
string | The formatted text | 1.86 |
Examples
Card with text
formatter using text from i18n resource bundle
i18n/i18n.properties
subtitle=Showing {0} of Total {1} Items
manifest.json
"sap.card": { "type": "List", "data": { "json": { "visibleItems": 5, "totalItems": 15 } }, "header": { "title": "Order Status", "subTitle": "{= format.text(${i18n>subtitle}, [${/visibleItems}, ${/totalItems}]}" }, "content": {...} }Try it Out