react-language-support

Easy to use multi-language support library for React

Usage no npm install needed!

<script type="module">
  import reactLanguageSupport from 'https://cdn.skypack.dev/react-language-support';
</script>

README

react-language-support

Easy to use multi-language support library for React

NPM JavaScript Style Guide

Documentation

http://react-language-support.tudorhutu.ro

Features

  • Create multiple language packs
  • Variable/Replacement support for text
  • Persistent storage of the preferred language
  • Fast and easy to use, with no almost no config at all

Install

npm install --save react-language-support

Usage

import React from 'react';

import {
  LanguageProvider,
  Lang,
  createLanguageConfig
} from 'react-language-support';

const languageConfig = {
  languages: {
    en: {
      hello: 'Hi {{name}}!'
    },
    fr: {
      hello: 'Bonjour {{name}}!'
    }
  }
};

const App = () => {
  return (
    <LanguageProvider config={createLanguageConfig(languageConfig)}>
      <Lang replace={{ name: 'John doe' }}>hello</Lang>
    </LanguageProvider>
  );
};

export default App;

Contribute

License

MIT © hututudor