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 的產品挪威製造