import React, { useEffect, useState } from 'react'; import T, { TProvider, useTranslation } from '@wojtekmaj/react-t/src'; import { useTick } from '@wojtekmaj/react-hooks'; import LocaleOptions from './LocaleOptions'; import PassingOptions from './PassingOptions'; import './Test.css'; import { languageFiles } from './i18n'; import type { PassMethod } from './shared/types'; function FancyJohn() { const tick = useTick(); const oneTwo = tick % 2 === 0; return ( {oneTwo ? '✨' : '🌟'} John {oneTwo ? '🌟' : '✨'} ); } function TestContent() { const stringOne = useTranslation('Hello world!'); const stringTwo = useTranslation('Hello {name}!', { name: 'John' }); const stringThree = useTranslation('Hello {name} and {other}!', { name: 'John', other: 'Elisabeth', }); const stringFour = useTranslation('Hello {name}! Nice to meet you {name}!', { name: 'John', }); const stringFive = useTranslation('Hello {name}!', { name: }); return (

Using T component

Hello world!

{`Hello {name}!`}

{`Hello {name} and {other}!`}

{`Hello {name}! Nice to meet you {name}!`}

}>{`Hello {name}!`}

Using useTranslation hook

{stringOne}

{stringTwo}

{stringThree}

{stringFour}

{stringFive}

); } export default function Test() { const [locale, setLocale] = useState(); const [passMethod, setPassMethod] = useState('attribute'); useEffect(() => { const html = document.documentElement; if (locale && passMethod === 'attribute') { html.setAttribute('lang', locale); } else { html.removeAttribute('lang'); } }, [locale, passMethod]); return (

react-t test page

); }