시작하기
설치
프로젝트에 TacoTranslate를 설치하려면 터미널을 열고 프로젝트의 루트 디렉터리로 이동하세요. 그런 다음, 다음 명령어를 실행하여 npm으로 설치하세요:
npm install tacotranslate
이것은 이미 프로젝트가 설정되어 있다고 가정합니다. 예제를 보려면 더 많은 정보를 확인하세요.
기본 사용법
아래 예제는 TacoTranslate
클라이언트를 생성하고, 애플리케이션을 TacoTranslate
프로바이더로 감싸며, Translate
컴포넌트를 사용하여 번역된 문자열을 표시하는 방법을 보여줍니다.
import createTacoTranslateClient from 'tacotranslate';
import {TacoTranslate, Translate} from 'tacotranslate/react';
const tacoTranslateClient = createTacoTranslateClient({apiKey: 'YOUR_API_KEY'});
function Page() {
return <Translate string="Hello, world!" />;
}
export default function App() {
return (
<TacoTranslate client={tacoTranslateClient} locale="es">
<Page />
</TacoTranslate>
);
}
예제는 스페인어 (locale="es"
)를 사용하도록 설정되어 있으므로, Translate
컴포넌트는 "¡Hola, mundo!"를 출력합니다.
예제
우리의 GitHub 예제 폴더로 이동하여 Next.js App Router 또는 Create React App과 같이 사용 사례에 맞게 TacoTranslate를 설정하는 방법에 대해 자세히 알아보세요.
우리는 또한 여러분이 여기에서 확인할 수 있는 CodeSandbox를 준비해 두었습니다.