From 84d4e96c6a7ac0756f61b54a8c97cbe1603bb9a8 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sun, 26 Jul 2015 14:34:47 +0200 Subject: [PATCH] Setup translation for security-guide-rst Follow setup of openstack-manuals for translation of RST files: * Add generatepot-rst tox environment (called by infra scripts) * Enable translation in doc-tools-check-languages.conf * Add file security-guide-rst/source/locale/security-guide-rst.pot (empty for now, the infra scripts will import the realy content) Change-Id: Iee728f9f0719fddf05cd67218e46694c0c6dee70 Partial-Implements: bp sec-guide-rst --- doc-tools-check-languages.conf | 4 +- .../source/locale/security-guide-rst.pot | 0 tools/generatepot-rst.sh | 42 +++++++++++++++++++ tox.ini | 5 +++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 security-guide-rst/source/locale/security-guide-rst.pot create mode 100755 tools/generatepot-rst.sh diff --git a/doc-tools-check-languages.conf b/doc-tools-check-languages.conf index 6873db2c..e0c21772 100644 --- a/doc-tools-check-languages.conf +++ b/doc-tools-check-languages.conf @@ -21,8 +21,8 @@ DOC_DIR="./" # Values need to match content in project-config/jenkins/scripts/common_translation_update.sh declare -A SPECIAL_BOOKS SPECIAL_BOOKS=( - # Skip translation of guide for now, it needs to consolidate first - ["security-guide-rst"]="skip" + # Directory is using RST + ["security-guide-rst"]="RST" # These are translated in openstack-manuals ["common-rst"]="skip" ) diff --git a/security-guide-rst/source/locale/security-guide-rst.pot b/security-guide-rst/source/locale/security-guide-rst.pot new file mode 100644 index 00000000..e69de29b diff --git a/tools/generatepot-rst.sh b/tools/generatepot-rst.sh new file mode 100755 index 00000000..e3184842 --- /dev/null +++ b/tools/generatepot-rst.sh @@ -0,0 +1,42 @@ +#!/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. + +DOCNAME=$1 + +if [ -z "$DOCNAME" ] ; then + echo "usage $0 DOCNAME" + exit 1 +fi + +# We're not doing anything for this directory. +if [[ "$DOCNAME" = "common-rst" ]] ; then + exit 0 +fi + +rm -f $DOCNAME/source/locale/$DOCNAME.pot +sphinx-build -b gettext $DOCNAME/source/ $DOCNAME/source/locale/ + +# common-rst is translated as part of openstack-manuals, do not +# include the file in the combined tree. +rm $DOCNAME/source/locale/common.pot + +# Take care of deleting all temporary files so that git add +# doc/$DOCNAME/source/locale will only add the single pot file. +# Remove UUIDs, those are not necessary and change too often +msgcat --sort-output $DOCNAME/source/locale/*.pot | \ + awk '$0 !~ /^\# [a-z0-9]+$/' > $DOCNAME/source/$DOCNAME.pot +rm $DOCNAME/source/locale/*.pot +rm -rf $DOCNAME/source/locale/.doctrees/ +mv $DOCNAME/source/$DOCNAME.pot $DOCNAME/source/locale/$DOCNAME.pot diff --git a/tox.ini b/tox.ini index 6155780d..62861b31 100644 --- a/tox.ini +++ b/tox.ini @@ -82,6 +82,11 @@ commands = # Build and copy RST Guides {toxinidir}/tools/build-all-rst.sh +[testenv:generatepot-rst] +# Generate POT files for translation, needs {posargs} like: +# tox -e generatepot-rst -- security-guide-rst +commands = {toxinidir}/tools/generatepot-rst.sh {posargs} + [doc8] # Settings for doc8: # This file has extra long lines that cannot be avoided, let's white list it.