Merge "Translation job scripts support multiple python modules"
This commit is contained in:
commit
225163c62d
@ -34,33 +34,29 @@ function get_modulename {
|
|||||||
-p $project -t $target
|
-p $project -t $target
|
||||||
}
|
}
|
||||||
|
|
||||||
# Setup a project for Zanata. This is used by both Python and Django
|
# Setup a project for Zanata. This is used by both Python and Django projects.
|
||||||
# projects.
|
# syntax: setup_project <project> <zanata_version> <modulename> [<modulename> ...]
|
||||||
function setup_project {
|
function setup_project {
|
||||||
local project=$1
|
local project=$1
|
||||||
local modulename=$2
|
local version=$2
|
||||||
local version=${3:-master}
|
shift 2
|
||||||
|
# All argument(s) contain module names now.
|
||||||
/usr/local/jenkins/slave_scripts/create-zanata-xml.py \
|
if [ $# -eq 1 ]; then
|
||||||
-p $project -v $version --srcdir $modulename/locale \
|
local modulename=$1
|
||||||
--txdir $modulename/locale -r '**/*.pot' \
|
/usr/local/jenkins/slave_scripts/create-zanata-xml.py \
|
||||||
'{locale_with_underscore}/LC_MESSAGES/{filename}.po' -f zanata.xml
|
-p $project -v $version --srcdir $modulename/locale \
|
||||||
|
--txdir $modulename/locale \
|
||||||
|
-r '**/*.pot' '{locale_with_underscore}/LC_MESSAGES/{filename}.po' \
|
||||||
|
-f zanata.xml
|
||||||
|
else
|
||||||
|
/usr/local/jenkins/slave_scripts/create-zanata-xml.py \
|
||||||
|
-p $project -v $version --srcdir . --txdir . \
|
||||||
|
-r '**/*.pot' '{path}/{locale_with_underscore}/LC_MESSAGES/{filename}.po' \
|
||||||
|
-f zanata.xml
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Setup project horizon for Zanata
|
|
||||||
function setup_horizon {
|
|
||||||
local project=horizon
|
|
||||||
local version=${1:-master}
|
|
||||||
|
|
||||||
/usr/local/jenkins/slave_scripts/create-zanata-xml.py -p $project \
|
|
||||||
-v $version --srcdir . --txdir . -r './horizon/locale/*.pot' \
|
|
||||||
'horizon/locale/{locale_with_underscore}/LC_MESSAGES/{filename}.po' \
|
|
||||||
-r './openstack_dashboard/locale/*.pot' \
|
|
||||||
'openstack_dashboard/locale/{locale_with_underscore}/LC_MESSAGES/{filename}.po' \
|
|
||||||
-e '.*/**' -f zanata.xml
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set global variable DocFolder for manuals projects
|
# Set global variable DocFolder for manuals projects
|
||||||
function init_manuals {
|
function init_manuals {
|
||||||
project=$1
|
project=$1
|
||||||
|
@ -20,10 +20,11 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
DJANGO_PROJECT_SUFFIXES = ('-dashboard',
|
DJANGO_PROJECT_SUFFIXES = (
|
||||||
'-horizon',
|
'-dashboard',
|
||||||
'-ui',
|
'horizon', # to match horizon and *-horizon
|
||||||
'django_openstack_auth',
|
'-ui',
|
||||||
|
'django_openstack_auth',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -100,13 +101,13 @@ def main():
|
|||||||
|
|
||||||
if 'openstack_translations' in config:
|
if 'openstack_translations' in config:
|
||||||
translate_options = get_translate_options(config, args.target)
|
translate_options = get_translate_options(config, args.target)
|
||||||
return translate_options
|
print(' '.join(translate_options))
|
||||||
|
return
|
||||||
|
|
||||||
modules = get_valid_modules(config, args.project, args.target)
|
modules = get_valid_modules(config, args.project, args.target)
|
||||||
|
|
||||||
# A shortest module name is selected now.
|
|
||||||
if modules:
|
if modules:
|
||||||
print(sorted(modules, key=len)[0])
|
print(' '.join(modules))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -74,11 +74,7 @@ function propose_training_guides {
|
|||||||
|
|
||||||
# Propose updates for python projects
|
# Propose updates for python projects
|
||||||
function propose_python {
|
function propose_python {
|
||||||
local project=$1
|
local modulename=$1
|
||||||
local modulename=$2
|
|
||||||
|
|
||||||
# Pull updated translations from Zanata
|
|
||||||
pull_from_zanata "$project"
|
|
||||||
|
|
||||||
# Extract all messages from project, including log messages.
|
# Extract all messages from project, including log messages.
|
||||||
extract_messages "$modulename"
|
extract_messages "$modulename"
|
||||||
@ -102,29 +98,9 @@ function propose_python {
|
|||||||
git add $modulename/locale/
|
git add $modulename/locale/
|
||||||
}
|
}
|
||||||
|
|
||||||
function propose_horizon {
|
|
||||||
|
|
||||||
# Pull updated translations from Zanata.
|
|
||||||
pull_from_zanata "$PROJECT"
|
|
||||||
|
|
||||||
# Invoke run_tests.sh to update the po files
|
|
||||||
# Or else, "../manage.py makemessages" can be used.
|
|
||||||
./run_tests.sh --makemessages -V
|
|
||||||
|
|
||||||
# Compress downloaded po files
|
|
||||||
compress_po_files "horizon"
|
|
||||||
compress_po_files "openstack_dashboard"
|
|
||||||
|
|
||||||
# Add all changed files to git
|
|
||||||
git add horizon/locale/ openstack_dashboard/locale/
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function can be used for all django projects
|
# This function can be used for all django projects
|
||||||
function propose_django {
|
function propose_django {
|
||||||
local project=$1
|
local modulename=$1
|
||||||
local modulename=$2
|
|
||||||
# Pull updated translations from Zanata.
|
|
||||||
pull_from_zanata "$project"
|
|
||||||
|
|
||||||
# Update the .pot file
|
# Update the .pot file
|
||||||
extract_messages_django "$modulename"
|
extract_messages_django "$modulename"
|
||||||
@ -152,25 +128,29 @@ case "$PROJECT" in
|
|||||||
setup_training_guides "$ZANATA_VERSION"
|
setup_training_guides "$ZANATA_VERSION"
|
||||||
propose_training_guides
|
propose_training_guides
|
||||||
;;
|
;;
|
||||||
horizon)
|
|
||||||
setup_horizon "$ZANATA_VERSION"
|
|
||||||
propose_horizon
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
# Common setup for python and django repositories
|
# Common setup for python and django repositories
|
||||||
# ---- Python projects ----
|
# ---- Python projects ----
|
||||||
MODULENAME=$(get_modulename $PROJECT python)
|
module_names=$(get_modulename $PROJECT python)
|
||||||
if [ -n "$MODULENAME" ]; then
|
if [ -n "$module_names" ]; then
|
||||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||||
setup_loglevel_vars
|
setup_loglevel_vars
|
||||||
propose_python "$PROJECT" "$MODULENAME"
|
# Pull updated translations from Zanata
|
||||||
|
pull_from_zanata "$PROJECT"
|
||||||
|
for modulename in $module_names; do
|
||||||
|
propose_python "$modulename"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- Django projects ----
|
# ---- Django projects ----
|
||||||
MODULENAME=$(get_modulename $PROJECT django)
|
module_names=$(get_modulename $PROJECT django)
|
||||||
if [ -n "$MODULENAME" ]; then
|
if [ -n "$module_names" ]; then
|
||||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||||
propose_django "$PROJECT" "$MODULENAME"
|
# Pull updated translations from Zanata.
|
||||||
|
pull_from_zanata "$PROJECT"
|
||||||
|
for modulename in $module_names; do
|
||||||
|
propose_django "$modulename"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -40,26 +40,26 @@ case "$PROJECT" in
|
|||||||
training-guides)
|
training-guides)
|
||||||
setup_training_guides "$ZANATA_VERSION"
|
setup_training_guides "$ZANATA_VERSION"
|
||||||
;;
|
;;
|
||||||
horizon)
|
|
||||||
setup_horizon "$ZANATA_VERSION"
|
|
||||||
./run_tests.sh --makemessages -V
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
# Common setup for python and django repositories
|
# Common setup for python and django repositories
|
||||||
# ---- Python projects ----
|
# ---- Python projects ----
|
||||||
MODULENAME=$(get_modulename $PROJECT python)
|
module_names=$(get_modulename $PROJECT python)
|
||||||
if [ -n "$MODULENAME" ]; then
|
if [ -n "$module_names" ]; then
|
||||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||||
setup_loglevel_vars
|
setup_loglevel_vars
|
||||||
extract_messages "$MODULENAME"
|
for modulename in $module_names; do
|
||||||
extract_messages_log "$MODULENAME"
|
extract_messages "$modulename"
|
||||||
|
extract_messages_log "$modulename"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- Django projects ----
|
# ---- Django projects ----
|
||||||
MODULENAME=$(get_modulename $PROJECT django)
|
module_names=$(get_modulename $PROJECT django)
|
||||||
if [ -n "$MODULENAME" ]; then
|
if [ -n "$module_names" ]; then
|
||||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||||
extract_messages_django "$MODULENAME"
|
for modulename in $module_names; do
|
||||||
|
extract_messages_django "$modulename"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user