react-hola
simple react language translation
Quick Start
npm install -save react-hola
Basic Usage
;; //define languageconst languagesData = "en-US": "main": "title": "hello world" "greet": "hello {{ name }}" //define a custom componentconst helloWorld = <div> <h2> propslangstitle </h2> <p> propslangs</p> </div> //generate new component with HOCconst HelloWorld = //will output hello world and hello charlieconst App = <InternationalProvider data=languagesData locale="en-US"> <HelloWorld /> </InternationalProvider>;
Component level translations
;; //define languageconst languagesData = "en-US": "main": "helloWorld": "title": "hello world" "greet": "hello {{ name }}" //define a custom componentconst helloWorld = <div> <h2> propslangstitle </h2> <p> propslangs</p> </div> //access component translation using dot notationconst HelloWorld = //will output hello world and hello charlieconst App = <InternationalProvider data=languagesData locale="en-US"> <HelloWorld /> </InternationalProvider>;
Share translation among component
;; //define languageconst languagesData = "en-US": "share": "UI": "title": "hello world" "main": "helloWorld": "greet": "hello {{ name }}" //define a custom componentconst helloWorld = <div> <h2> propslangstitle </h2> <p> propslangs</p> </div> //access multiple component translationconst HelloWorld = //will output hello world and hello charlieconst App = <InternationalProvider data=languagesData locale="en-US"> <HelloWorld /> </InternationalProvider>;