/issues-translation

Use AI/GPT to translate GitHub issues into English.

Primary LanguagePythonMIT LicenseMIT

issues-translation

Use AI/GPT to translate GitHub issues into English.

Usage

Use docker to translate issue:

docker run -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx \
  --rm -it ossrs/issues-translation:v1 \
  python issue-trans.py --input https://github.com/your-org/your-repository/issues/3692

Use docker to translate discussion:

docker run -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx \
  --rm -it ossrs/issues-translation:v1 \
  python discussion-trans.py --input https://github.com/your-org/your-repository/discussions/3700

Use docker to translate PR:

docker run -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx \
  --rm -it ossrs/issues-translation:v1 \
  python pr-trans.py --input https://github.com/your-org/your-repository/pull/3699

Run GitHub webhooks server:

docker run -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx \
 --rm -it -p 2023:2023 ossrs/issues-translation:v1 \
  python server.py --listen 2023 --forward https://discord.com/xxx

Also you can use --env-file=$(pwd)/.env to load the environment variables from file .env.

Developer

Write a .env file to setup OpenAI API key and GitHub token:

#.env
GITHUB_TOKEN=xxx
OPENAI_API_KEY=xxx
OPENAI_PROXY=xxx

Note: The GITHUB_TOKEN is required to update the issue ,please read Authenticating to the REST API to create one.

Note: The OPENAI_API_KEY is required, which is the API key for OpenAI API.

Note: The OPENAI_PROXY is optional, which is the proxy for OpenAI API.

Note: Or save the above environment variables to .env.

For fist run, create venv then install dependencies:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Translate issues to English:

python issue-trans.py --input https://github.com/your-org/your-repository/issues/3692

Translate issues to English:

python pr-trans.py --input https://github.com/your-org/your-repository/pull/3699
python pr-rephrase.py --input https://github.com/your-org/your-repository/pull/3699

Translate discussions to English:

python discussion-trans.py --input https://github.com/your-org/your-repository/discussions/3700

Once translated, this tool appends a MAGIC string to the conclusion of the text body to prevent repeated translations.