그 useT hook
가끔은 일반 HTML 콘텐츠 말고 다른 것을 번역해야 할 때가 있어.이를 위해 Magic Translate 는 useT hook 제공돼.예를 들어 props 번역에 쓸 수 있어.
import { useT } from '@magic-translate/react';const MyComponent = () => {const t = useT();return (<button aria-label={t('Main menu')}><HamburgerIcon /></button>);};
구성 요소 내부 어디에서나 t() 함수를 사용할 수 있어.원한다면 마크업에서 <T> 컴포넌트 대신 사용할 수도 있어.
const MyComponent = () => {const t = useT();return <p>{t('This will be translated')}</p>;};
옵션들
t() 에도 <T> 구성 요소와 동일한 옵션을 전달할 수 있어, 예를 들어 formality.
const MyComponent = () => {const t = useT();return <button>{t('Please click here', { formality: 'formal' })}</button>;};