1.0.14 • Published 4 years ago

pubcore-ui-text v1.0.14

Weekly downloads
20
License
MIT
Repository
github
Last release
4 years ago

DEPRECATED, please use pubcore/ui-text instead

Build Status

Map keys to text with replacement-tag support

To support multilingual user interfaces one option is to use key-value lists of texts. Instead of writing the text directly into a document, a text-key is used to look up the text to show.

An other benefit is to decouple developer work from content management work, if texts are not known at time of development.

Configuration

import {initLogMissingTextkey} from 'pubcore-ui-text'

//enable post log-infos, if there are missing text-keys
initLogMissingTextkey({postUri:'https://xyz.com/'})

Examples

import uiText from 'pubcore-ui-text'

//example-data with text-key "content" and it's text string having
//one replacement-tag "count":
var T = {
    content: '{count} item(s)'
}

console.log( uiText(T, 'content', {count:5}) )
//output: '5 item(s)'

//we can add some inline default text:
console.log( uiText(T, 'word_count', 'Found {count} words', {count:2}) )
//output: "Found 2 words"

codepen example

https://codepen.io/pubcore/pen/JrLaap

1.0.14

4 years ago

1.0.12

4 years ago

1.0.11

5 years ago

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago