1.0.5 • Published 4 years ago

text-provider-react-native v1.0.5

Weekly downloads
6
License
MIT
Repository
-
Last release
4 years ago

It provides two components:

  1. TextProvider
  2. FormattedMessage

Install

npm i text-provider-react-native

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.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago