TacoTranslate
/
文档定价
 
  1. 介绍
  2. 快速开始
  3. 设置和配置
  4. 使用 TacoTranslate
  5. 服务器端渲染
  6. 高级用法
  7. 最佳实践
  8. 错误处理与调试
  9. 支持的语言

快速开始

安装

To install TacoTranslate in your application, open your terminal and navigate to the root directory of your project. Then, run the following command to install with npm:

npm install tacotranslate

This assumes you already have an application set up. See examples for more information.

基本用法

下面的示例演示如何创建一个 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!".

创建 API 密钥

示例

请前往 我们的 GitHub 示例文件夹,了解如何针对您的用例专门设置 TacoTranslate,例如使用 Next.js App Router 或 Create React App。

我们还设置了一个 CodeSandbox,你可以 在这里查看

设置和配置

Nattskiftet 提供的产品挪威制造