Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-ziqi committed Jul 3, 2024
1 parent 1c4ea78 commit cb9ce8c
Show file tree
Hide file tree
Showing 851 changed files with 112 additions and 109,805 deletions.
23 changes: 0 additions & 23 deletions .dockerignore

This file was deleted.

23 changes: 0 additions & 23 deletions .flake8

This file was deleted.

54 changes: 0 additions & 54 deletions .github/ISSUE_TEMPLATE/bug.md

This file was deleted.

37 changes: 0 additions & 37 deletions .github/ISSUE_TEMPLATE/proposal.md

This file was deleted.

13 changes: 0 additions & 13 deletions .github/ISSUE_TEMPLATE/question.md

This file was deleted.

4 changes: 0 additions & 4 deletions .github/LICENSE_HEADER.txt

This file was deleted.

56 changes: 0 additions & 56 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

62 changes: 0 additions & 62 deletions .github/stale.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/translate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import requests

# 获取 GitHub Token
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
GITHUB_REPO = 'fan-ziqi/IsaacLab'

headers = {
'Authorization': f'token {GITHUB_TOKEN}',
'Accept': 'application/vnd.github.v3+json'
}

def translate_text(text, target_language):
url = f'https://api.github.com/repos/{GITHUB_REPO}/contents/{file_path}'
params = {
'text': text,
'target_language': target_language
}
response = requests.post(url, headers=headers, json=params)
if response.status_code == 200:
return response.json()['translated_text']
else:
print(f"Error: {response.status_code} - {response.text}")
return text

def translate_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
translated = translate_text(content, 'zh')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(translated)

def translate_all_html_files(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.html'):
file_path = os.path.join(root, file)
translate_file(file_path)
print(f'Translated {file_path}')

# 假设工作目录是仓库的根目录
translate_all_html_files('.')
70 changes: 70 additions & 0 deletions .github/workflows/translate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Sync, Translate and Update
on:
schedule:
- cron: '0 * * * *' # 每小时运行一次
jobs:
sync-and-translate:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository
uses: actions/checkout@v2
with:
repository: fan-ziqi/IsaacLab
ref: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}

- name: Add upstream repository
run: |
git remote add upstream https://github.com/isaac-sim/IsaacLab.git
git fetch upstream
- name: Check for changes in upstream gh-pages
id: check_changes
run: |
UPSTREAM_COMMIT=$(git rev-parse upstream/gh-pages)
LOCAL_COMMIT=$(git rev-parse origin/gh-pages)
echo "UPSTREAM_COMMIT=$UPSTREAM_COMMIT" >> $GITHUB_ENV
echo "LOCAL_COMMIT=$LOCAL_COMMIT" >> $GITHUB_ENV
if [ "$UPSTREAM_COMMIT" == "$LOCAL_COMMIT" ]; then
echo "No changes in upstream."
exit 0
fi
- name: Sync fork's gh-pages with upstream
if: env.UPSTREAM_COMMIT != env.LOCAL_COMMIT
run: |
git checkout gh-pages
git merge upstream/gh-pages
git push origin gh-pages
- name: Create or checkout gh-pages-zhcn branch
if: env.UPSTREAM_COMMIT != env.LOCAL_COMMIT
run: |
if git show-ref --verify --quiet refs/heads/gh-pages-zhcn; then
git checkout gh-pages-zhcn
else
git checkout -b gh-pages-zhcn
fi
- name: Setup Python
if: env.UPSTREAM_COMMIT != env.LOCAL_COMMIT
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
if: env.UPSTREAM_COMMIT != env.LOCAL_COMMIT
run: |
pip install requests
- name: Translate content to Chinese
if: env.UPSTREAM_COMMIT != env.LOCAL_COMMIT
run: |
python translate.py
- name: Commit and push changes
if: env.UPSTREAM_COMMIT != env.LOCAL_COMMIT
run: |
git add .
git commit -m "Translate changes to Chinese"
git push origin gh-pages-zhcn
Loading

0 comments on commit cb9ce8c

Please sign in to comment.