Skip to content

Commit

Permalink
docs: auto translate
Browse files Browse the repository at this point in the history
  • Loading branch information
fan-ziqi committed Jul 4, 2024
1 parent 455a174 commit b8cbf12
Show file tree
Hide file tree
Showing 702 changed files with 344,252 additions and 35 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/sync-and-translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Sync and Translate Documentation

on:
schedule:
- cron: '0 0 * * *' # 每天 UTC 时间午夜运行一次
workflow_dispatch:

jobs:
sync-and-translate:
runs-on: ubuntu-latest

steps:
- name: Checkout user's repo (main branch)
uses: actions/checkout@v2
with:
repository: fan-ziqi/IsaacLab
ref: main

- name: Configure Git user
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Add upstream repository
run: git remote add upstream https://github.com/isaac-sim/IsaacLab.git

- name: Merge upstream changes while keeping local changes
run: |
git fetch upstream
git checkout main
git merge upstream/main -X ours --allow-unrelated-histories
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools polib==1.2.0 openai==v1.3.6 python-dotenv==1.0.0 pytest==8.2.2 sphinx-intl sphinx-book-theme==1.0.1 myst-parser sphinxcontrib-bibtex==2.5.0 autodocsumm sphinx-copybutton sphinx-icon sphinx_design sphinxemoji numpy matplotlib warp-lang gymnasium
- name: Generate gettext
run: |
pushd docs
make gettext
popd
- name: Update translations
run: |
pushd docs
sphinx-intl update -p _build/gettext -l zh_CN
popd
- name: Translate using custom script
run: |
pushd docs
python po_translator.py --folder ./locale --lang zh_CN --folder-language --bulk
popd
- name: Build HTML with translations
run: make -e SPHINXOPTS="-D language='zh_CN'" -C docs html

- name: Copy generated HTML files to user repo
run: |
mkdir -p temp_html
cp -r docs/_build/html/* temp_html/
- name: Commit and push gettext and po files to main branch
run: |
git add -f docs/_build/gettext/*
git add -f docs/_build/html/*
git add -f docs/locale/zh_CN/LC_MESSAGES/**/*.po
git commit -m "Update gettext and po files"
git push origin main
- name: Commit and push changes to gh-pages-zhcn branch
run: |
git checkout --orphan gh-pages-zhcn
git rm -rf .
cp -r temp_html/* .
rm -rf temp_html
rm -rf docs
git add .
git commit -m "Update translated documentation"
git push origin gh-pages-zhcn --force
3 changes: 3 additions & 0 deletions docker/.env.base
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ DOCKER_USER_HOME=/root
# Cluster specific settings
###

# Job scheduler used by cluster.
# Currently supports PBS and SLURM
CLUSTER_JOB_SCHEDULER=SLURM
# Docker cache dir for Isaac Sim (has to end on docker-isaac-sim)
# e.g. /cluster/scratch/$USER/docker-isaac-sim
CLUSTER_ISAAC_SIM_CACHE_DIR=/some/path/on/cluster/docker-isaac-sim
Expand Down
23 changes: 23 additions & 0 deletions docker/cluster/submit_job_pbs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# in the case you need to load specific modules on the cluster, add them here
# e.g., `module load eth_proxy`

# create job script with compute demands
### MODIFY HERE FOR YOUR JOB ###
cat <<EOT > job.sh
#!/bin/bash
#PBS -l select=1:ncpus=8:mpiprocs=1:ngpus=1
#PBS -l walltime=01:00:00
#PBS -j oe
#PBS -q gpu
#PBS -N isaaclab
#PBS -m bea -M "user@mail"
# Pass the container profile first to run_singularity.sh, then all arguments intended for the executed script
sh "$1/docker/cluster/run_singularity.sh" "$2" "${@:3}"
EOT

qsub job.sh
rm job.sh
File renamed without changes.
28 changes: 24 additions & 4 deletions docker/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,28 @@ x11_cleanup() {
fi
}

submit_job() {

echo "[INFO] Arguments passed to job script ${@}"

case $CLUSTER_JOB_SCHEDULER in
"SLURM")
CMD=sbatch
job_script_file=submit_job_slurm.sh
;;
"PBS")
CMD=bash
job_script_file=submit_job_pbs.sh
;;
*)
echo "[ERROR] Unsupported job scheduler specified: '$CLUSTER_JOB_SCHEDULER'. Supported options are: ['SLURM', 'PBS']"
exit 1
;;
esac

ssh $CLUSTER_LOGIN "cd $CLUSTER_ISAACLAB_DIR && $CMD $CLUSTER_ISAACLAB_DIR/docker/cluster/$job_script_file \"$CLUSTER_ISAACLAB_DIR\" \"isaac-lab-$container_profile\" ${@}"
}

#==
# Main
#==
Expand Down Expand Up @@ -372,12 +394,10 @@ case $mode in
# check whether the second argument is a profile or a job argument
if [ "$profile_arg" == "$container_profile" ] ; then
# if the second argument is a profile, we have to shift the arguments
echo "[INFO] Arguments passed to job script ${@:3}"
ssh $CLUSTER_LOGIN "cd $CLUSTER_ISAACLAB_DIR && sbatch $CLUSTER_ISAACLAB_DIR/docker/cluster/submit_job.sh" "$CLUSTER_ISAACLAB_DIR" "isaac-lab-$container_profile" "${@:3}"
submit_job "${@:3}"
else
# if the second argument is a job argument, we have to shift only one argument
echo "[INFO] Arguments passed to job script ${@:2}"
ssh $CLUSTER_LOGIN "cd $CLUSTER_ISAACLAB_DIR && sbatch $CLUSTER_ISAACLAB_DIR/docker/cluster/submit_job.sh" "$CLUSTER_ISAACLAB_DIR" "isaac-lab-$container_profile" "${@:2}"
submit_job "${@:2}"
fi
;;
config)
Expand Down
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ Execute the following instructions to build the documentation (assumed from the
# open on default browser
xdg-open _build/html/index.html
```

```bash
make gettext
sphinx-intl update -p _build/gettext -l zh_CN
python po_translator.py --folder ./locales --lang zh_CN --folder-language --bulk
make -e SPHINXOPTS="-D language='zh_CN'" html
```
101 changes: 101 additions & 0 deletions docs/_build/gettext/_sphinx_design_static/design-tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// @ts-check

// Extra JS capability for selected tabs to be synced
// The selection is stored in local storage so that it persists across page loads.

/**
* @type {Record<string, HTMLElement[]>}
*/
let sd_id_to_elements = {};
const storageKeyPrefix = "sphinx-design-tab-id-";

/**
* Create a key for a tab element.
* @param {HTMLElement} el - The tab element.
* @returns {[string, string, string] | null} - The key.
*
*/
function create_key(el) {
let syncId = el.getAttribute("data-sync-id");
let syncGroup = el.getAttribute("data-sync-group");
if (!syncId || !syncGroup) return null;
return [syncGroup, syncId, syncGroup + "--" + syncId];
}

/**
* Initialize the tab selection.
*
*/
function ready() {
// Find all tabs with sync data

/** @type {string[]} */
let groups = [];

document.querySelectorAll(".sd-tab-label").forEach((label) => {
if (label instanceof HTMLElement) {
let data = create_key(label);
if (data) {
let [group, id, key] = data;

// add click event listener
// @ts-ignore
label.onclick = onSDLabelClick;

// store map of key to elements
if (!sd_id_to_elements[key]) {
sd_id_to_elements[key] = [];
}
sd_id_to_elements[key].push(label);

if (groups.indexOf(group) === -1) {
groups.push(group);
// Check if a specific tab has been selected via URL parameter
const tabParam = new URLSearchParams(window.location.search).get(
group
);
if (tabParam) {
console.log(
"sphinx-design: Selecting tab id for group '" +
group +
"' from URL parameter: " +
tabParam
);
window.sessionStorage.setItem(storageKeyPrefix + group, tabParam);
}
}

// Check is a specific tab has been selected previously
let previousId = window.sessionStorage.getItem(
storageKeyPrefix + group
);
if (previousId === id) {
// console.log(
// "sphinx-design: Selecting tab from session storage: " + id
// );
// @ts-ignore
label.previousElementSibling.checked = true;
}
}
}
});
}

/**
* Activate other tabs with the same sync id.
*
* @this {HTMLElement} - The element that was clicked.
*/
function onSDLabelClick() {
let data = create_key(this);
if (!data) return;
let [group, id, key] = data;
for (const label of sd_id_to_elements[key]) {
if (label === this) continue;
// @ts-ignore
label.previousElementSibling.checked = true;
}
window.sessionStorage.setItem(storageKeyPrefix + group, id);
}

document.addEventListener("DOMContentLoaded", ready, false);

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/_build/gettext/_static/twemoji.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
img.emoji {
height: 1em;
width: 1em;
margin: 0 .05em 0 .1em;
vertical-align: -0.1em;
}
10 changes: 10 additions & 0 deletions docs/_build/gettext/_static/twemoji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function addEvent(element, eventName, fn) {
if (element.addEventListener)
element.addEventListener(eventName, fn, false);
else if (element.attachEvent)
element.attachEvent('on' + eventName, fn);
}

addEvent(window, 'load', function() {
twemoji.parse(document.body, {'folder': 'svg', 'ext': '.svg'});
});
Loading

0 comments on commit b8cbf12

Please sign in to comment.