New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

aikit-translator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aikit-translator

AI-powered translation package for React applications

latest
Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

ai-translator

Repository

  • GitHub Repository

Introduction

ai-translator is a React internationalization translation toolkit based on multiple AI models (such as ChatGPT, Grok, and DeepSeek), supporting multi-language batch translation, automatic extraction of translation keys, command-line batch processing, type safety, and high extensibility.

Features

  • Supports multiple AI translation models (ChatGPT, Grok, DeepSeek)
  • Supports mutual translation for 30+ commonly used languages
  • Supports automatic extraction of translation keys from React components and t() functions
  • Provides CLI tools for batch translation and key extraction
  • Type-safe and easily extensible
  • Supports multiple runtime environments (Node.js, Vite, Webpack)

Installation

npm install ai-translator
# or
pnpm add ai-translator

Usage in React

import { TranslationProvider, useTranslation } from "ai-translator";

function App() {
  return (
    <TranslationProvider
      config={{
        model: "chatgpt", // Supports chatgpt/grok/deepseek
        apiKey: "your-api-key",
        sourceLanguage: "en",
        targetLanguage: "zh",
      }}
    >
      <YourComponent />
    </TranslationProvider>
  );
}

function YourComponent() {
  const { translate, currentLanguage, setLanguage, isLoading } =
    useTranslation();

  const handleTranslate = async () => {
    const result = await translate("Hello, world!");
    console.log(result.text); // 你好,世界!
  };

  return (
    <div>
      <button onClick={handleTranslate} disabled={isLoading}>
        {isLoading ? "Translating..." : "Translate"}
      </button>
    </div>
  );
}

CLI Usage

Extract Translation Keys and Auto-Translate

npx ai-translator extract -i "src/**/*.{ts,tsx,js,jsx}" -o locales/en.json --translate -l zh ja ko fr de es ...

Directly Translate Files or Directories

npx ai-translator translate -f ./locales/en.json -m chatgpt -s en -t zh ja ko
npx ai-translator translate -d ./locales -m deepseek -s en -t fr de es

Extract and Translate in One Step

npx ai-translator i18n -i "src/**/*.{ts,tsx,js,jsx}" -o locales/en.json -m grok -s en -t zh ja ko fr de es

Supported Languages

  • English (en), Simplified Chinese (zh), Traditional Chinese (zh-TW), Japanese (ja), Korean (ko)
  • French (fr), German (de), Spanish (es), Italian (it), Portuguese (pt)
  • Russian (ru), Arabic (ar), Turkish (tr), Vietnamese (vi), Thai (th)
  • Indonesian (id), Hindi (hi), Malay (ms), Persian (fa), Hebrew (he)
  • Polish (pl), Dutch (nl), Swedish (sv), Finnish (fi), Danish (da)
  • Norwegian (no), Czech (cs), Greek (el), Hungarian (hu), Romanian (ro)

API Reference

TranslationProvider Props

PropTypeRequiredDescription
configTranslationConfigYesTranslation configuration

TranslationConfig

PropTypeRequiredDescription
model'grok' | 'chatgpt' | 'deepseek'YesAI translation model
apiKeystringYesAPI key
sourceLanguagestringYesSource language
targetLanguagestringYesTarget language
baseUrlstringNoAPI base URL

useTranslation Hook

Returns:

PropTypeDescription
translate(text: string) => PromiseTranslate text
currentLanguageLanguageCurrent language
setLanguage(lang: Language) => voidSet language
isLoadingbooleanWhether translating

Environment Variables

  • AI_TRANSLATOR_API_KEY: API key for AI model

License

MIT

For detailed documentation, secondary development, or enterprise customization, please contact the imtom.eth@gmail.com.

Keywords

translation

FAQs

Package last updated on 07 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts