GitHub Action to translate Documentation to any language
This is a GitHub Action that automatically translate the documentation in your repo to a specified language.
- Add a workflow file to your project (e.g.
.github/workflows/documentation.yml
):
name: Translate DOCUMENTATION
on:
push:
branches:
- main
- master
jobs:
translate:
runs-on: ubuntu-latest
strategy:
matrix:
language:
- { code: zh-CN, name: Chinese Simplified }
- { code: zh-TW, name: Chinese Traditional }
- { code: hi, name: Hindi }
- { code: ar, name: Arabic }
- { code: fr, name: French }
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x # Updated to a more recent LTS version
- name: Adding DOCUMENTATION - ${{ matrix.language.name }}
uses: vanHeemstraSystems/translate-documentation@main
with:
LANG: ${{ matrix.language.code }}
Do the following:
Linux / macOS:
$ export NODE_OPTIONS=--openssl-legacy-provider
Windows:
$ setx NODE_OPTIONS=--openssl-legacy-provider
Then:
$ npm run build
A new package will be build and stored in the dist
directory.
You can configure the action further with the following options:
LANG
: The language you want to translate your documentation to. The default is Simplified Chinese. The supported languages can be found below. (default:zh-CH
) (required:false
)
Languages supported can be found here https://cloud.google.com/translate/docs/languages
Check here for issues related to this action.
Suggestions and contributions are always welcome!