Support translation of RST files

The OpenStack manuals are switching to some RST files. Enhance our
scripts so that they can handle RST files in manual projects.

Change-Id: Ie3e9591d2aad88aced3092aa2a8919af186ce83d
Depends-On: I3124cf65b254c1c5aefce59447bb94240d96a742
This commit is contained in:
Andreas Jaeger 2015-03-06 11:38:50 +01:00
parent 59db4150c9
commit e8e61d6107
2 changed files with 35 additions and 10 deletions

View File

@ -82,6 +82,11 @@ function init_manuals {
# operations-guide) for transifex
function setup_manuals {
local project=$1
# Fill in associative array SPECIAL_BOOKS
declare -A SPECIAL_BOOKS
source doc-tools-check-languages.conf
# Generate pot one by one
for FILE in ${DocFolder}/*; do
# Skip non-directories
@ -93,10 +98,6 @@ function setup_manuals {
if [[ "$DOCNAME" =~ ^(www|tools|generated|publish-docs)$ ]]; then
continue
fi
# Ignore directories starting with playground
if [[ "$DOCNAME" =~ "^playground" ]]; then
continue
fi
# Skip glossary in all repos besides openstack-manuals.
if [ "$project" != "openstack-manuals" -a "$DOCNAME" == "glossary" ]; then
continue
@ -113,17 +114,38 @@ function setup_manuals {
PERC=8
fi
fi
# Update the .pot file
./tools/generatepot ${DOCNAME}
if [ -f ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot ]; then
# Add all changed files to git
git add ${DocFolder}/${DOCNAME}/locale/*
IS_RST=0
if [ ${SPECIAL_BOOKS["${DOCNAME}"]+_} ] ; then
if [ ${SPECIAL_BOOKS["${DOCNAME}"]} == "RST" ] ; then
IS_RST=1
fi
if [ ${SPECIAL_BOOKS["${DOCNAME}"]} == "skip" ] ; then
continue
fi
fi
if [ ${IS_RST} -eq 1 ] ; then
tox -e generatepot-rst -- ${DOCNAME}
git add ${DocFolder}/${DOCNAME}/source/locale/${DOCNAME}.pot
# Set auto-local
tx set --auto-local -r openstack-manuals-i18n.${DOCNAME} \
"${DocFolder}/${DOCNAME}/locale/<lang>.po" --source-lang en \
"${DocFolder}/${DOCNAME}/source/locale/<lang>/LC_MESSAGES/${DOCNAME}.po" \
--source-lang en \
--source-file ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot \
--minimum-perc=$PERC \
-t PO --execute
else
# Update the .pot file
./tools/generatepot ${DOCNAME}
if [ -f ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot ]; then
# Add all changed files to git
git add ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot
# Set auto-local
tx set --auto-local -r openstack-manuals-i18n.${DOCNAME} \
"${DocFolder}/${DOCNAME}/locale/<lang>.po" --source-lang en \
--source-file ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot \
--minimum-perc=$PERC \
-t PO --execute
fi
fi
done

View File

@ -47,6 +47,9 @@ for FILE in ${DocFolder}/*; do
if [ -d ${DocFolder}/${DOCNAME}/locale ] ; then
git add ${DocFolder}/${DOCNAME}/locale/*
fi
if [ -d ${DocFolder}/${DOCNAME}/source/locale ] ; then
git add ${DocFolder}/${DOCNAME}/source/locale/*
fi
done
filter_commits