mirror of
https://github.com/tuxbox-neutrino/buildenv.git
synced 2025-08-26 15:02:58 +02:00
.github/workflow: update yaml
use only .github/workflows/translateandtag.yml as workflow
This commit is contained in:
25
.github/scripts/translate.py
vendored
25
.github/scripts/translate.py
vendored
@@ -1,25 +0,0 @@
|
|||||||
from googletrans import Translator
|
|
||||||
|
|
||||||
def translate_readme(input_text, target_lang):
|
|
||||||
translator = Translator()
|
|
||||||
translated = translator.translate(input_text, dest=target_lang)
|
|
||||||
translated_text = translated.text
|
|
||||||
|
|
||||||
# add hint for automatically translation
|
|
||||||
translated_text = f"Note: This is an automatically translated file. Original content from [here](https://github.com/tuxbox-neutrino/buildenv/blob/3.2.4/README-de.md):\n\n{translated_text}"
|
|
||||||
|
|
||||||
# Use this workaround, because translater breaks some links and anchors
|
|
||||||
translated_text = translated_text.replace("[Build Image](#Build Image)", "[Build Image](#build-image)")
|
|
||||||
translated_text = translated_text.replace("devtool -reference.html", "devtool-reference.html")
|
|
||||||
translated_text = translated_text.replace("dev-manual -common-tasks.html", "dev-manual-common-tasks.html")
|
|
||||||
translated_text = translated_text.replace("Clone #1-Init-Script", "#1-clone-init-script")
|
|
||||||
|
|
||||||
return translated_text
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
input_text = open("README-de.md", "r").read()
|
|
||||||
target_lang = "en" # target language is english
|
|
||||||
translated_text = translate_readme(input_text, target_lang)
|
|
||||||
|
|
||||||
with open("README-en.md", "w") as outfile:
|
|
||||||
outfile.write(translated_text)
|
|
42
.github/workflows/readme.yml
vendored
42
.github/workflows/readme.yml
vendored
@@ -1,42 +0,0 @@
|
|||||||
name: Translate README
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 3.2.4
|
|
||||||
paths:
|
|
||||||
- 'README-de.md'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
translate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install --upgrade googletrans==3.1.0a0
|
|
||||||
|
|
||||||
- name: Translate README
|
|
||||||
run: |
|
|
||||||
python .github/scripts/translate.py
|
|
||||||
|
|
||||||
- name: Commit and push translated README
|
|
||||||
run: |
|
|
||||||
git config --global user.email "actions@github.com"
|
|
||||||
git config --global user.name "GitHub Actions"
|
|
||||||
git add README-en.md
|
|
||||||
git commit -m "readme: Automatically translated README to English"
|
|
||||||
git push
|
|
||||||
|
|
84
.github/workflows/translateandtag.yml
vendored
Normal file
84
.github/workflows/translateandtag.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
name: Translate README
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'README_de.md'
|
||||||
|
- 'init.sh'
|
||||||
|
- 'config/config-sample.php'
|
||||||
|
- 'privacy.php'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
translate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
|
||||||
|
- name: Install translate dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install --upgrade googletrans==3.1.0a0
|
||||||
|
curl -o translate-md.py https://raw.githubusercontent.com/dbt1/translate-md/refs/heads/master/translate-md.py
|
||||||
|
chmod 755 translate-md.py
|
||||||
|
curl -o translate-md-config.json https://raw.githubusercontent.com/dbt1/translate-md/refs/heads/master/translate-md-config.json.sample
|
||||||
|
|
||||||
|
- name: Prepare Git user data
|
||||||
|
run: |
|
||||||
|
git config --global user.email "dbt@novatux.de"
|
||||||
|
git config --global user.name "Thilo Graf"
|
||||||
|
|
||||||
|
- name: Verify translate-md.py download
|
||||||
|
run: |
|
||||||
|
if [ ! -f translate-md.py ]; then
|
||||||
|
echo "translate-md.py was not downloaded!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Translate README
|
||||||
|
run: |
|
||||||
|
cp README_de.md template.md
|
||||||
|
python translate-md.py --template-md template.md --output-dir . --prefix README_ --main-doc README.md -c translate-md-config.json -s de
|
||||||
|
rm template.md
|
||||||
|
|
||||||
|
- name: Commit and push translated README
|
||||||
|
run: |
|
||||||
|
git add README*.md
|
||||||
|
git commit -m "readme: Automatically translated README"
|
||||||
|
git push
|
||||||
|
|
||||||
|
- name: Install tagit dependencies
|
||||||
|
run: |
|
||||||
|
pip install GitPython
|
||||||
|
curl -o tagit.py https://raw.githubusercontent.com/dbt1/tagit/master/tagit.py
|
||||||
|
curl -o tagit-config.json https://raw.githubusercontent.com/dbt1/tagit/master/tagit-config.json
|
||||||
|
chmod +x tagit.py
|
||||||
|
|
||||||
|
- name: Verify tagit.py download
|
||||||
|
run: |
|
||||||
|
if [ ! -f tagit.py ]; then
|
||||||
|
echo "tagit.py was not downloaded!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Tagging
|
||||||
|
run: |
|
||||||
|
python tagit.py -f README_de.md -f README_en.md -f README_es.md -f README_fr.md -f README_it.md --scheme-file tagit-config.json
|
||||||
|
|
||||||
|
- name: Commit and push version and tag changes
|
||||||
|
run: |
|
||||||
|
git add -A
|
||||||
|
git commit -m "Automatically updated tags [skip ci]" || echo "No changes to commit"
|
||||||
|
git push
|
||||||
|
git push --tags
|
Reference in New Issue
Block a user