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 1193d7c
Show file tree
Hide file tree
Showing 178 changed files with 94,420 additions and 1 deletion.
85 changes: 85 additions & 0 deletions .github/workflows/sync-and-translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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/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
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'});
});
133 changes: 133 additions & 0 deletions docs/_build/gettext/index.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2022-2024, The Isaac Lab Project Developers.
# This file is distributed under the same license as the Isaac Lab package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Isaac Lab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-04 12:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../../index.rst:58
msgid "Getting Started"
msgstr ""

#: ../../index.rst:69
msgid "Features"
msgstr ""

#: ../../index.rst:80
msgid "Resources"
msgstr ""

#: ../../index.rst:89
msgid "Source API"
msgstr ""

#: ../../index.rst:95
msgid "Migration Guides"
msgstr ""

#: ../../index.rst:104
msgid "References"
msgstr ""

#: ../../index.rst:115
msgid "GitHub"
msgstr ""

#: ../../index.rst:115
msgid "NVIDIA Isaac Sim"
msgstr ""

#: ../../index.rst:115
msgid "NVIDIA PhysX"
msgstr ""

#: ../../index.rst:115
msgid "Project Links"
msgstr ""

#: ../../index.rst:2
msgid "Overview"
msgstr ""

#: ../../index.rst:-1
msgid "H1 Humanoid example using Isaac Lab"
msgstr ""

#: ../../index.rst:8
msgid "**Isaac Lab** is a unified and modular framework for robot learning that aims to simplify common workflows in robotics research (such as RL, learning from demonstrations, and motion planning). It is built upon `NVIDIA Isaac Sim`_ to leverage the latest simulation capabilities for photo-realistic scenes, and fast and efficient simulation. The core objectives of the framework are:"
msgstr ""

#: ../../index.rst:13
msgid "**Modularity**: Easily customize and add new environments, robots, and sensors."
msgstr ""

#: ../../index.rst:14
msgid "**Agility**: Adapt to the changing needs of the community."
msgstr ""

#: ../../index.rst:15
msgid "**Openness**: Remain open-sourced to allow the community to contribute and extend the framework."
msgstr ""

#: ../../index.rst:16
msgid "**Battery-included**: Include a number of environments, sensors, and tasks that are ready to use."
msgstr ""

#: ../../index.rst:18
msgid "Key features available in Isaac Lab include fast and accurate physics simulation provided by PhysX, tiled rendering APIs for vectorized rendering, domain randomization for improving robustness and adaptability, and support for running in the cloud."
msgstr ""

#: ../../index.rst:22
msgid "For more information about the framework, please refer to the `paper <https://arxiv.org/abs/2301.04195>`_ :cite:`mittal2023orbit`. For clarifications on NVIDIA Isaac ecosystem, please check out the :doc:`/source/setup/faq` section."
msgstr ""

#: ../../index.rst:-1
msgid "Example tasks created using Isaac Lab"
msgstr ""

#: ../../index.rst:32
msgid "License"
msgstr ""

#: ../../index.rst:34
msgid "The Isaac Lab framework is open-sourced under the BSD-3-Clause license. Please refer to :ref:`license` for more details."
msgstr ""

#: ../../index.rst:38
msgid "Acknowledgement"
msgstr ""

#: ../../index.rst:39
msgid "Isaac Lab development initiated from the `Orbit <https://isaac-orbit.github.io/>`_ framework. We would appreciate if you would cite it in academic publications as well:"
msgstr ""

#: ../../index.rst:56
msgid "Table of Contents"
msgstr ""

#: ../../index.rst:124
msgid "Indices and tables"
msgstr ""

#: ../../index.rst:126
msgid ":ref:`genindex`"
msgstr ""

#: ../../index.rst:127
msgid ":ref:`modindex`"
msgstr ""

#: ../../index.rst:128
msgid ":ref:`search`"
msgstr ""
Loading

0 comments on commit 1193d7c

Please sign in to comment.