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>
);
npm i react-localization-experiment
yarn add react-localization-experiment
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;
}>;
react-localization-experiment
is MIT licensed