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ผลิตในนอร์เวย์