yuwuxing / xliff-gpt-translator

Xliff GPT Translator is a Node.js application that automatically translates XLIFF files using the OpenAI Chat API. It reads XLIFF files from an input directory, translates them into the target language, and saves the translated files in an output directory.
MIT License
3 stars 1 forks source link

Xliff GPT Translator

English | 简体中文

Xliff GPT Translator is a Node.js application that automatically translates XLIFF files using the OpenAI Chat API. It reads XLIFF files from an input directory, translates them into the target language, and saves the translated files in an output directory.

Features

Getting Started

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/yuwuxing/xliff-gpt-translator
  1. Install dependencies:
cd xliff-gpt-translator
npm install
  1. Configure the application by updating config.json:

Replace YOUR_API_KEY with your OpenAI API key:

{
  "openai_api_key": "YOUR_API_KEY",
  "openai_api_baseurl": "https://api.openai.com",
  "openai_model": "gpt-3.5-turbo",
  "inputDir": "./xliff",
  "outputDir": "./output",
  "finishedDir": "./finished",
  "rateLimit": 3,
  "nodesPerRequest": 5
}

Usage

  1. Place the XLIFF files you want to translate in the ./xliff directory (or a custom input directory specified in config.json).

  2. Run the application:

node index.js
  1. The translated files will be saved in the ./output directory (or a custom output directory specified in config.json).

  2. The original files will be moved to the ./finished directory (or a custom finished directory specified in config.json).

Customization

You can customize the application by modifying the settings in config.json:

Contributing

Pull requests are welcome! Please make sure to update tests as appropriate and follow the existing code style.

License

This project is licensed under the MIT License. For more details, see the LICENSE file.