🌐 GPT-Translate Project Overview
Introduction
The GPT-Translate project is a GitHub action designed to translate markdown files into multiple languages using a variety of AI models. The project aims to simplify the translation process by leveraging AI technology to convert textual content into different languages seamlessly.
Current Status
Currently, the GPT-Translate action supports the translation of markdown (.md
), markdown-jsx (.mdx
), and JSON (.json
) files. Only individuals with write permissions to a repository can execute translation commands, which helps prevent potential abuse of the API by unauthorized users.
Setup
Repository Configuration
To get started with GPT-Translate, several repository settings need adjustment:
- Under
Settings > Actions > General
, enable both "Read and write permissions" and "Allow GitHub Actions to create and approve pull requests". - In
Settings > Secrets and variables > Actions
, set your API key, such asOPENAI_API_KEY
, to maintain security.
Workflow Settings
To integrate GPT-Translate into your GitHub actions, follow these key steps:
- Essential: Include the
OPENAI_API_KEY
asapiKey
and set the action to trigger upon the creation of comments (types: [ created ]
). - Recommended: Optimize workflows by specifying triggers for comments containing
/gpt-translate
or/gt
.
Below is a basic workflow example to kickstart your translation tasks:
# .github/workflows/gpt-translate.yml
name: GPT Translate
on:
issue_comment:
types: [ created ]
jobs:
gpt_translate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run GPT Translate
if: |
contains(github.event.comment.body, '/gpt-translate') ||
contains(github.event.comment.body, '/gt')
uses: 3ru/gpt-translate@master
with:
apikey: ${{ secrets.OPENAI_API_KEY }}
Usage
The GPT-Translate action can be initiated through comments in issues or pull requests using the following command format:
/gpt-translate [input filepath] [output filepath] [target language]
You can substitute /gpt-translate
with /gt
for convenience. The translation process will either create a new pull request (if initiated from an issue) or add to an existing pull request with new commits (if initiated from a pull request).
Example
Here is an example command to translate a README.md
file into traditional Chinese:
/gpt-translate README.md zh-TW/README.md traditional-chinese
This command translates the specified file and saves it in the zh-TW
directory.
Features
One of the features of GPT-Translate is its ability to handle multiple files simultaneously by using wildcards in the input file path, allowing translations to be executed on several files at once.
Supported Languages
GPT-Translate can translate content into any language that is interpreted by GPT-4 or GPT-3.5 models, offering a wide range of language support.
Community Engagement
The GPT-Translate project encourages community participation through GitHub discussions and issue tracking:
- Discussions are open for user queries and general engagement.
- Issues can be submitted for bug reports or feature requests.
License
The project is licensed under the MIT License, promoting openness and collaboration.
By blending powerful AI models with an easy-to-use GitHub action, GPT-Translate provides an efficient tool for multilingual content creation and management in software projects.