forked from isaac-sim/IsaacLab
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
851 changed files
with
112 additions
and
109,805 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.