From e8e61d610725193b8482260697c849d697332a56 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Fri, 6 Mar 2015 11:38:50 +0100 Subject: [PATCH] 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 --- jenkins/scripts/common_translation_update.sh | 42 ++++++++++++++----- .../propose_translation_update_manuals.sh | 3 ++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/jenkins/scripts/common_translation_update.sh b/jenkins/scripts/common_translation_update.sh index c70b42ea13..b9ea83a134 100644 --- a/jenkins/scripts/common_translation_update.sh +++ b/jenkins/scripts/common_translation_update.sh @@ -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/.po" --source-lang en \ + "${DocFolder}/${DOCNAME}/source/locale//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/.po" --source-lang en \ + --source-file ${DocFolder}/${DOCNAME}/locale/${DOCNAME}.pot \ + --minimum-perc=$PERC \ + -t PO --execute + fi fi done diff --git a/jenkins/scripts/propose_translation_update_manuals.sh b/jenkins/scripts/propose_translation_update_manuals.sh index 99e216a322..118a90fa59 100755 --- a/jenkins/scripts/propose_translation_update_manuals.sh +++ b/jenkins/scripts/propose_translation_update_manuals.sh @@ -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