Skip to content

Commit

Permalink
feat: Automate README translations (#624)
Browse files Browse the repository at this point in the history
Draft PR for #600

> Some known issues that are to be fixed yet (this is just a draft PR)

- The workflow takes too long for translations, approx. ~10 mins, may
batch translating content be helpful?
- Code blocks are exempted from translations due to unexpected
translations of syntax
- Hyperlinks for TOC currently aren't being translated

Currently the translator uses Google AJAX Api for translations so the
translations may not be "good". Best approach would perhaps be utilizing
machine translation instead.

<!-- ELLIPSIS_HIDDEN -->

----

> [!IMPORTANT]
> Automates translation of `README.md` into multiple languages using a
GitHub workflow and Python script, preserving code blocks and HTML tags.
> 
>   - **Workflow**:
> - Adds `.github/workflows/translate-readme.yml` to automate
translation of `README.md` on push.
> - Uses `deep-translator` and `parmapper` for translation and parallel
processing.
>     - Translates into Chinese, Japanese, and French.
>   - **Script**:
> - `scripts/readme_translator.py` translates `README.md`, preserving
code blocks and HTML tags.
> - Uses `GoogleTranslator` from `deep-translator` for language
translation.
> - Saves translated files as `README-CN.md`, `README-JA.md`,
`README-FR.md`.
>   - **Known Issues**:
>     - Translation process is slow (~10 mins), potential for batching.
>     - Code blocks and TOC links are not translated.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=julep-ai%2Fjulep&utm_source=github&utm_medium=referral)<sup>
for 020e102. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: itsamziii <[email protected]>
Co-authored-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
4 people authored Oct 13, 2024
1 parent e02ee06 commit 958217f
Show file tree
Hide file tree
Showing 6 changed files with 2,716 additions and 464 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/translate-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Translate ReadME

on:
push:
paths:
- "README.md"

jobs:
readme-translator:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Python v3.10.12
uses: actions/setup-python@v5
with:
python-version: "3.10.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install deep-translator git+https://github.com/Jwink3101/parmapper
- name: Run translator script
run: python scripts/readme_translator.py

- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README-*.md
git commit -m "chore(readme): translate README.md"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
Loading

0 comments on commit 958217f

Please sign in to comment.