Fix translation setup for api-site

After a recent change to api-site, the translation scripts tried to
translate the www directory which is wrong.

This patch  unifies the translation setup of both propose and upstream
jobs into the common library and enhances the initial setup so that it
skips non-directories (like pom.xml) and special directories like www
and tools.

Change-Id: I9402d75ca9c8df67c62c56bbad582cb1166824c6
This commit is contained in:
Andreas Jaeger 2014-06-01 09:18:53 +02:00
parent 6630433ffd
commit f86e137683
3 changed files with 52 additions and 45 deletions

View File

@ -63,6 +63,51 @@ function setup_horizon ()
-t PO --execute
}
# Set global variable DocFolder for manuals projects
function init_manuals ()
{
project=$1
DocFolder="doc"
if [ $project = "api-site" ] ; then
DocFolder="./"
fi
}
# Setup project manuals projects (api-site, openstack-manuals,
# operations-guide) for transifex
function setup_manuals ()
{
# Generate pot one by one
for FILE in ${DocFolder}/*
do
# Skip non-directories
if [ ! -d $FILE ]
then
continue
fi
DOCNAME=${FILE#${DocFolder}/}
# Ignore directories that will not get translated
if [ "$DOCNAME" == "www" -o "$DOCNAME" == "tools" -o "$DOCNAME" == "generated" -o "$DOCNAME" == "publish-docs" ]
then
continue
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/*
# 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 \
-t PO --execute
fi
done
}
# Setup git so that git review works
function setup_git ()
{

View File

@ -20,34 +20,15 @@
ORG="openstack"
PROJECT=$1
DocFolder="doc"
if [ $PROJECT = "api-site" ] ; then
DocFolder="./"
fi
source /usr/local/jenkins/slave_scripts/common_translation_update.sh
init_manuals "$PROJECT"
setup_git
setup_review "$ORG" "$PROJECT"
setup_translation
# Generate pot one by one
for FILE in ${DocFolder}/*
do
DOCNAME=${FILE#${DocFolder}/}
# 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/*
# 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 \
-t PO --execute
fi
done
setup_manuals
# Pull upstream translations of files that are at least 75 %
# translated
@ -61,7 +42,7 @@ if [ $PROJECT = "openstack-manuals" ] ; then
tx pull -f --minimum-perc=8 -r openstack-manuals-i18n.common
fi
# Add imported upstream translations to git
for FILE in ${DocFolder}/*
do
DOCNAME=${FILE#${DocFolder}/}

View File

@ -18,11 +18,6 @@
PROJECT=$1
DocFolder="doc"
if [ $PROJECT = "api-site" ] ; then
DocFolder="./"
fi
if [ ! `echo $ZUUL_REFNAME | grep master` ]
then
exit 0
@ -30,26 +25,12 @@ fi
source /usr/local/jenkins/slave_scripts/common_translation_update.sh
init_manuals "$PROJECT"
setup_git
setup_translation
# Generate pot one by one
for FILE in ${DocFolder}/*
do
DOCNAME=${FILE#${DocFolder}/}
# 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/*
# 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 \
-t PO --execute
fi
done
setup_manuals
if [ ! `git diff --cached --quiet HEAD --` ]
then