From 670c7af1ad78e8af3a62886d2a5ff5fe644eb7c5 Mon Sep 17 00:00:00 2001 From: daisy-ycguo Date: Thu, 5 Mar 2015 18:25:29 +0800 Subject: [PATCH] First step for translation of RST files Set locale_dirs in conf.py to support translated documents building. Add a config variable SPECIAL_BOOKS to list documents in RST format. Add new generatepot-rst tox environment to generate all pot file, invoke using "tox -e generatepot-rst -- playground-user-guide". Add new script to generate the pot files. Co-Authored-By: Andreas Jaeger Change-Id: I3124cf65b254c1c5aefce59447bb94240d96a742 --- doc-tools-check-languages.conf | 9 +++++++ doc/hot-guide/source/conf.py | 3 +++ doc/networking-guide/source/conf.py | 3 +++ doc/playground-user-guide/source/conf.py | 3 +++ tools/generatepot-rst.sh | 32 ++++++++++++++++++++++++ tox.ini | 5 ++++ 6 files changed, 55 insertions(+) create mode 100755 tools/generatepot-rst.sh diff --git a/doc-tools-check-languages.conf b/doc-tools-check-languages.conf index 0c579828f5..56e0a53b5e 100644 --- a/doc-tools-check-languages.conf +++ b/doc-tools-check-languages.conf @@ -20,3 +20,12 @@ POM_FILE="doc/pom.xml" # Location of doc dir DOC_DIR="doc/" + +# Books with special handling +# Values need to match content in project-config/jenkins/scripts/common_translation_update.sh +declare -A SPECIAL_BOOKS +SPECIAL_BOOKS=( + ["playground-user-guide"]="RST" + ["networking-guide"]="skip" + ["hot-guide"]="skip" +) diff --git a/doc/hot-guide/source/conf.py b/doc/hot-guide/source/conf.py index e60728a5d5..09e3c61e33 100644 --- a/doc/hot-guide/source/conf.py +++ b/doc/hot-guide/source/conf.py @@ -267,3 +267,6 @@ texinfo_documents = [ # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False + +# -- Options for Internationalization output ------------------------------ +locale_dirs = ['locale/'] diff --git a/doc/networking-guide/source/conf.py b/doc/networking-guide/source/conf.py index b64250ce77..3252389257 100644 --- a/doc/networking-guide/source/conf.py +++ b/doc/networking-guide/source/conf.py @@ -269,3 +269,6 @@ texinfo_documents = [ # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False + +# -- Options for Internationalization output ------------------------------ +locale_dirs = ['locale/'] diff --git a/doc/playground-user-guide/source/conf.py b/doc/playground-user-guide/source/conf.py index 45454671b1..6ed800c669 100644 --- a/doc/playground-user-guide/source/conf.py +++ b/doc/playground-user-guide/source/conf.py @@ -268,3 +268,6 @@ texinfo_documents = [ # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False + +# -- Options for Internationalization output ------------------------------ +locale_dirs = ['locale/'] diff --git a/tools/generatepot-rst.sh b/tools/generatepot-rst.sh new file mode 100755 index 0000000000..b0c92be8d9 --- /dev/null +++ b/tools/generatepot-rst.sh @@ -0,0 +1,32 @@ +#!/bin/bash -xe + +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Copy files from trunk to named branch and replace all links from +# trunk with links to the branch + +DOCNAME=$1 + +if [ -z "$DOCNAME" ] ; then + echo "usage $0 DOCNAME" + exit 1 +fi + +sphinx-build -b gettext doc/$DOCNAME/source/ doc/$DOCNAME/source/locale/ + +# Take care of deleting all temporary files so that git add +# doc/$DOCNAME/source/locale will only add the single pot file. +msgcat doc/$DOCNAME/source/locale/*.pot > doc/$DOCNAME/source/DOCNAME.pot +rm doc/$DOCNAME/source/locale/*.pot +mv doc/$DOCNAME/source/DOCNAME.pot doc/$DOCNAME/source/locale/DOCNAME.pot diff --git a/tox.ini b/tox.ini index 4f5c83e7b2..bd66607e45 100644 --- a/tox.ini +++ b/tox.ini @@ -104,6 +104,11 @@ sitepackages=True whitelist_externals = doc-tools-check-languages commands = doc-tools-check-languages doc-tools-check-languages.conf publish all +[testenv:generatepot-rst] +# Generate POT files for translation, needs {posargs} like: +# tox -e generatepot-rst -- playground-user-guide +commands = {toxinidir}/tools/generatepot-rst.sh {posargs} + [doc8] # Settings for doc8: # Ignore target directories