1.1.3 • Published 3 years ago

text-provider v1.1.3

Weekly downloads
93
License
MIT
Repository
github
Last release
3 years ago

Text provider is a library to place all the string constants of an application in a single place and use them inside the components in a memory friendly way.

It provides two components:

  1. TextProvider
  2. FormattedMessage

Install

npm i text-provider

Usage

  1. Import the string constants required for the particular presentational component:
const sampleText = require("src/nls/sample-text.json");
  1. Use the TextProvider to make it available for all the components:
<TextProvider globalText={sampleText} >
  <MyPresentationalComponent />
</TextProvider>
  1. Use it inside the presentational component:
<FormattedMessage id="Random Id"/>
const randomId = "Random Id";
const values = {
  "valueToBeInjected": "Random Value"
};

<FormattedMessage id={randomId} values={values}/>

Works like a format string also. Example JSON:

{
  "Random Id": "<b>Random Text Returns</b> {valueToBeInjected} for each text)"
}

Then ${valueToBeInjected} gets replaced with the value specified in values.

Make sure that a string by the same id exists in the JSON file.

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.34

4 years ago

0.0.33

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.29

4 years ago

0.0.27

4 years ago

0.0.28

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago