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 的产品挪威制造