This Action Automatically translate a Markdown file (e.g., README.md) to any other language using options. However, this action does not process the html tags and other complex formatting in markdown file. Some features are still in development phases.
English - Hindi - French - Arabic - Chinese - Espanol
Auto Translate is a GitHub Action that uses Google Translate to create translated copies of Markdown files in your repository. This is especially useful for repositories with a global audience, making documentation accessible in multiple languages.
- Translates Markdown files to any specified language.
- Commits the translated file to the repository.
- Configurable commit message, committer, and additional commit options.
For an live firetest, please click here to see a perfect example of this Action.
Add the following to your .github/workflows/translate.yml
workflow file to set up Auto Translate in your repository:
name: Translate Action
on:
push:
branches:
- main
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Auto Translate
uses: offensive-vk/auto-translate@v7
with:
file: 'README.md'
language: 'es'
- name: Commit and Push
uses: offensive-vk/auto-commit-push@v7
with:
branch: 'master'
name: 'TheHamsterBot'
email: '[email protected]'
github-token: ${{ secrets.BOT_TOKEN }}
message: 'CI: Translated Markdown File.'
This example translates the README.md
file to Spanish (es
) and the translated file README.es.md
to the repository.
Input Name | Description | Required | Default |
---|---|---|---|
file |
Path of the file to translate (relative to repository root). | No | README.md |
repo-token |
GitHub token used to authenticate commits. Use ${{ secrets.GITHUB_TOKEN }} in workflows. |
No | |
committer |
The name of the committer for the commit. | No | github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
commit-options |
Additional options for the git commit command. |
No | |
language |
The target language code for translation (e.g., es , zh-CN , fr ). |
No | es |
name: Translate Multilingual Readme
on:
workflow_dispatch:
jobs:
translate:
strategy:
matrix:
lang: ['es', 'hi', 'fr', 'zh-CN', 'ar']
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Auto Translate README to French
uses: offensive-vk/auto-translate@master
with:
file: 'README.md'
language: ${{ matrix.lang }}
- name: Commit and Push
uses: offensive-vk/auto-commit-push@v7
with:
branch: 'master'
name: 'TheHamsterBot'
email: '[email protected]'
github-token: ${{ secrets.BOT_TOKEN }}
message: 'Translated Markdown ${{ matrix.lang }} File.'
Use any language code supported by Google Translate (e.g., es
for Spanish, zh-CN
for Simplified Chinese, fr
for French). For a full list, see Google Translate Language Codes.
If you want to build and test the action locally, you can use act to run GitHub Actions in your local environment. We are constantly scaling our services and the flexiblity of our continuous integration and our backend systems.
# Install dependencies
pnpm i
# Run action locally
act -j translate
- Ensure that you add a valid
github-token
in your workflow for commit authentication. - Translation quality depends on Google Translate and may vary based on language.
Contributions are welcome! Feel free to submit issues, feature requests, or pull requests.
Created by Vedansh (offensive-vk).
This project is licensed under the MIT License.
© Vedansh 2020 - Present
Licensed under MIT
Thanks for visiting :)