An open API service indexing awesome lists of open source software.

https://github.com/ryanhex53/gpt-po

command tool for translate po files by using openai api
https://github.com/ryanhex53/gpt-po

chatgpt gettext openai translation

Last synced: 7 months ago
JSON representation

command tool for translate po files by using openai api

Awesome Lists containing this project

README

          

# PO File Translation Tool for ChatGPT

[![NPM version](https://img.shields.io/npm/v/gpt-po.svg)](https://npmjs.org/package/gpt-po)
[![Downloads](https://img.shields.io/npm/dm/gpt-po.svg)](https://npmjs.org/package/gpt-po)

Translation tool for gettext (po) files that supports custom system prompts and user dictionaries. It also supports translating specified po files to a designated target language and updating po files based on pot files.

Read in other languages: English | [简体中文](./README_zh-CN.md)

Buy Me A Coffee

## Installation

```
npm install gpt-po
```

Set `OPENAI_API_KEY` before using this tool.

**It is recommended to use the paid OpenAI API to improve translation speed, as the free OpenAI API is slower (only 3 translations per minute) and has usage restrictions.**

## Usage Scenarios

- `gpt-po sync --po --pot ` Update the po file based on the pot file, while preserving the original translations.
- `gpt-po --po ` Translate specified po files to a designated target language.
- `gpt-po --po --lang ` Translate specified po files to a designated target language (overriding language specified in po file).
- `gpt-po --dir .` Translate all po files in current directory to a designated target language.
- `gpt-po userdict` Modify or view user dictionaries
- `gpt-po userdict --explore` Explore user dictionaries, if you want add new dictionaries or modify existing dictionaries. dictionaries can be named as `dictionary-.json`, for example, `dictionary-zh.json` is the dictionary for Simplified Chinese.

```
Usage: gpt-po [options] [command]

command tool for translate po files by gpt

Options:
-V, --version output the version number
-h, --help display help for command

Commands:
translate [options] translate po file (default command)
sync [options] update po from pot file
userdict [options] open/edit user dictionary
remove [options] remove po entries by options
help [command] display help for command
```

```
Usage: gpt-po [options]

translate po file (default command)

Options:
-k, --key openai api key (env: OPENAI_API_KEY)
--host openai api host (env: OPENAI_API_HOST)
--model openai model (default: "gpt-4o-mini", env: OPENAI_MODEL)
--po po file path
--dir po file directory
-src, --source source language (default: "english")
--verbose show verbose log
-l, --lang target language (ISO 639-1 code)
-o, --output output file path, overwirte po file by default
--context context file path (provides additional context to the bot)
--context-length Maximum accumulated length of source strings (msgid) to translate in each API request (default: 2000, env: API_CONTEXT_LENGTH)
--timeout Timeout in milliseconds for API requests (default: 20000, env: API_TIMEOUT)
-h, --help display help for command
```

```
Usage: gpt-po remove [options]

remove po entries by options

Options:
--po po file path
--fuzzy remove fuzzy entries
-obs, --obsolete remove obsolete entries
-ut, --untranslated remove untranslated entries
-t, --translated remove translated entries
-tnf, --translated-not-fuzzy remove translated not fuzzy entries
-ft, --fuzzy-translated remove fuzzy translated entries
-rc, --reference-contains remove entries whose reference contains text, text can be a regular expression like /text/ig
-h, --help display help for command
```

```
Usage: gpt-po sync [options]

update po from pot file

Options:
--po po file path
--pot pot file path
-h, --help display help for command
```