theJian/deepseek-translator

DeepSeek Translator is a command-line tool that translates i18next JSON files using the DeepSeek's AI.

โ˜… 1Forks 0PythonGitHub โ†—Compare
deepseeki18nextinternationalization

README

DeepSeek Translator

Python Version License: MIT

Overview

DeepSeek Translator is a tool that translates i18next JSON files using DeepSeek's AI. It provides a command-line interface and GitHub Action to integrate into workflows.

  • ๐Ÿ” Smart Key Detection: Only translates keys missing in target file
  • ๐ŸŒ Language Support: Translates between any language pair supported by DeepSeek
  • ๐Ÿง  Context-Aware: Uses JSON keys as context for accurate translations
  • ๐Ÿ”„ Merge Capabilities: Preserves existing translations
uvx --from git+https://github.com/theJian/deepseek-translator@main deepseek-translator \
  --source-lang en \
  --target-lang zh \
  --source-file locales/en.json \
  --target-file locales/zh.json

Prerequisites

Configuration

# Set API token
export DEEPSEEK_API_KEY='your_api_token_here'

The translator uses deepseek-v4-flash by default. Override it with --model deepseek-v4-pro or the DEEPSEEK_MODEL environment variable.

Create i18n.yaml in your project root:

# Each group defines source + target files
- en: "locales/en.json"       # First language = source
  ja: "locales/ja.json"       # Target languages
  es: "locales/es.json"

- en: "messages/main.json"    # Another group
  fr: "messages/fr.json"
  de: "messages/de.json"

Usage

Without a configuration file, you can run the command directly:

uvx --from git+https://github.com/theJian/deepseek-translator@main deepseek-translator \
  --source-lang en \
  --source-lang en \
  --target-lang zh \
  --source-file locales/en.json \
  --target-file locales/zh.json

With the configuration file i18n.yaml in the project root, run:

uvx --from git+https://github.com/theJian/deepseek-translator@main deepseek-translator

CLI Arguments

Argument Description
--config Custom config file path
--source-lang Source language code (e.g., 'en')
--target-lang Target language code (e.g., 'zh')
--source-file Path to source JSON file
--target-file Path to target JSON file
--model DeepSeek model ID (default: deepseek-v4-flash)
--verbose Enable detailed debug logging

GitHub Action

Check the example

Create .github/workflows/i18n.yml.

      - uses: actions/checkout@v4
      - uses: theJian/deepseek-translator@v2
        with:
          deepseek-api-key: ${{ secrets.DEEPSEEK_API_KEY }}
      - uses: peter-evans/create-pull-request@v7 # Or commit it using stefanzweifel/git-auto-commit-action

License

MIT

Contributors

theJian

Issues