跳转到内容

快速开始

  1. 安装 Tyndale

    Terminal window
    npm install tyndale tyndale-react
  2. 初始化你的项目

    Terminal window
    npx tyndale init

    这会使用默认设置创建 tyndale.config.json

  3. 通过你的 AI provider 进行认证

    Terminal window
    npx tyndale auth

    按照提示配置你的 API key(Anthropic、OpenAI 等)。

  4. 包裹可翻译内容

    import { T, useTranslation } from 'tyndale-react';
    export function Welcome() {
    const t = useTranslation();
    return (
    <div>
    <T>Welcome to our app!</T>
    <p>{t('You have {count} items', { count: 3 })}</p>
    </div>
    );
    }
  5. 提取并翻译

    Terminal window
    npx tyndale translate

    Tyndale 会扫描你的源文件,提取可翻译字符串,并为所有已配置的 locale 生成翻译。

Tyndale 扫描了你 JSX 中的 <T> 组件和 useTranslation() 调用,提取英文源文本,将其发送给你的 AI provider 进行翻译,并把 locale 文件写入你的 output 目录。

不需要 key 文件。不需要手动编辑 JSON。你的翻译已经就绪。