react-localization-experiment
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

react-localization-experiment

import React from 'react';

import { addDictionary, LocaleProvider, L } from 'react-localization-experiment';

addDictionary([
  {
    en: "hello",
    ru: "привет"
  },
  {
    en: "world",
    ru: "мир"
  }
]);

const App = () => (
  <LocaleProvider srcLocale="en" locale="ru">
    <div>
      <L>Hello, world!</L>
      {/* Привет, мир! */}

      <L from="ru" to="en">Привет, мир!</L>
      {/* Hello, world! */}
    </div>
  </LocaleProvider>
);

CodeSandbox

Installation

npm

npm i react-localization-experiment

Yarn

yarn add react-localization-experiment

API

declare function addDictionary(
  translations: Array<{ [lang: string]: string }>
): void;

declare function translate(
  text: string,
  fromLang: string,
  toLang: string
): string;

declare const LocaleProvider: React.FC<{
  srcLocale: string;
  locale: string;
  children?: any[];
}>;

declare const L: React.FC<{
  children: string;
  from: string;
  to: string;
}>;

License

react-localization-experiment is MIT licensed

Readme

Keywords

none

Package Sidebar

Install

npm i react-localization-experiment

Weekly Downloads

1

Version

0.1.8

License

MIT

Unpacked Size

8.03 kB

Total Files

21

Last publish

Collaborators

  • artemir