Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.
/ uiText Public archive

DEPRECATED use pubcore/ui-text instead; Map keys to text with replacement-tag support

Notifications You must be signed in to change notification settings

pubcore/uiText

Repository files navigation

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

About

DEPRECATED use pubcore/ui-text instead; Map keys to text with replacement-tag support

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •