Skip to content
book-open

GitHub Action

Auto Translate Readme

v2 Latest version

Auto Translate Readme

book-open

Auto Translate Readme

Automatically translate the language of README via Github Action

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Auto Translate Readme

uses: Lin-jun-xiang/action-translate-readme@v2

Learn more about this action in Lin-jun-xiang/action-translate-readme

Choose a version

action-translate-readme

Introduction

Note

The v1 version of the translator is implemented through Linux third-party packages; the v2 version is implemented through generative AI for translation.

  • We all know that writing README documents is time-consuming, 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 through generative AI

  • Automatically submit (commit, push) the translated files through Github Actions (CI/CD)

  • For example: writing or modifying the English version README, automatically generate Traditional Chinese, Simplified Chinese, French, etc. versions of README

How to use ?

Important

Since generative AI models have a chance of producing problematic 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 the steps below to ensure that a Token has been created, or check if the Token has expired!

  1. Click the ⭐ icon to add this project to your Github repository.

  2. Set up your Github Token:

    • Create a new Github Secret Token

      • Setup
      • Developer settings
      • Personal access tokens - Tokens(classic)
      • Generate new token
      • Select token lifecycle - recommended to use unlimited
      • Select scopes: repo and workflow
      • Keep your secret token (do not lose it, you will need to paste it later)
    • Create a new repository secret

      • In your repository - settings
      • Securities and variables
      • Actions
      • New repository secret
      • Fill in the label with token and name it (e.g., Action_Bot)
  3. GPT Model Selection

    • g4f: Default uses g4f for OpenAI calls and completes translation tasks.
    • zhipuai: If you need stable translation, you can register an account on the Zhipu AI Platform and apply for an API KEY. This is a completely free, no-credit-card-required GPT model solution
      • If you want to use this solution, please follow the steps in step 2 to apply for a Github Token and add the Zhipu AI API KEY to the Repo as an environment variable.

  4. Create your action example 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
                    zhipuai: ${{ secrets.zhipuai_api_key }} # Based on step3
                    langs: "en,zh-TW,zh-CN,French,Arabic" # You can define any langs
    

    Pay special attention to three parameters in the .yml:

    • token: Based on step 2, the token created in repos
    • zhipuai: The provider of GPT, if provided, use the Zhipu AI platform model, otherwise default to g4f, needs to be created in repos
    • langs: The language versions you want to generate, make 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
  5. Now you can update README.md, it will automatically generate a translated version!


Demo


Results of Test Document

  • View the test document
  • Use our tool to update the test document

Back to top