GitHub Action
Auto Translate Readme
Note
The translator of version v1
is implemented through a third-party package on Linux
; version v2
is implemented by calling the OpenAI API for free through g4f
.
-
We all know that writing README documentation takes a lot of time, but now there is a solution that can save you half the time. This is our
action-translate-readme
. -
Translate different language versions of README using
gpt3.5
. -
Automatically commit (commit, push) the translated files through Github Actions (CI/CD).
-
For example: Write or modify the English version of README, and automatically generate versions of README in Traditional Chinese, Simplified Chinese, French, etc.
Important
Since gpt3.5
is a generative AI model, there is a chance of problems with the translation results each time. It is recommended to use branch testing and try several times.
Warning
If you encounter the following error: Error: Input required and not supplied: token
, please follow step two to ensure that the Token
has been created or whether the Token
has expired!
-
Click on the ⭐ icon to add this project to your Github repository.
-
Set up your
Github Token
:-
Create a new
Github Secret Token
- Setting
- Developer settings
- Personal access tokens -
Tokens (classic)
- Generate new token
- Choose token lifespan - it is recommended to use unlimited
- Choose scopes:
repo
andworkflow
- Keep your secret token (do not lose it, you will need to paste it later)
-
Create a new
repository secret
- In your repository -
settings
Securits and variables
Actions
New repository secret
- Fill in the label with
token
and name it (eg:Action_Bot
)
- In your repository -
-
-
Create an example of your action in the directory
.github/workflows/your_action.yml
. You can directly copy the following:# .github/workflows/translate.yml name: Translate Readme on: push: branches: ['**'] jobs: translate: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 3 - name: Auto Translate uses: Lin-jun-xiang/action-translate-readme@v2 # Based on the tag with: token: ${{ secrets.Action_Bot }} # Based on step2 name g4f_provider: g4f.Provider.DeepAi # You can change this provider langs: "en,zh-TW,zh-CN,French,Arabic" # You can define any langs
There are three parameters in
.yml
that need special attention:token
: The token created in the repos based on step 2.g4f_provider
: The provider of gpt, for more information, please refer to the linklangs
: The language versions you want to generate, be sure to separate different languages with,
, for example:"en"
: Translate only the English version"en,zh-TW"
: Translate English and Traditional Chinese"French,Arabic"
: Translate French and Arabic
-
Now you can update
README.md
, and it will automatically generate a translated version!
- View the test document
- Use our tool to update the test document