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
|
||||
}
|
||||
|
||||
# Setup a project for Zanata. This is used by both Python and Django
|
||||
# projects.
|
||||
# Setup a project for Zanata. This is used by both Python and Django projects.
|
||||
# syntax: setup_project <project> <zanata_version> <modulename> [<modulename> ...]
|
||||
function setup_project {
|
||||
local project=$1
|
||||
local modulename=$2
|
||||
local version=${3:-master}
|
||||
|
||||
/usr/local/jenkins/slave_scripts/create-zanata-xml.py \
|
||||
-p $project -v $version --srcdir $modulename/locale \
|
||||
--txdir $modulename/locale -r '**/*.pot' \
|
||||
'{locale_with_underscore}/LC_MESSAGES/{filename}.po' -f zanata.xml
|
||||
local version=$2
|
||||
shift 2
|
||||
# All argument(s) contain module names now.
|
||||
if [ $# -eq 1 ]; then
|
||||
local modulename=$1
|
||||
/usr/local/jenkins/slave_scripts/create-zanata-xml.py \
|
||||
-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
|
||||
function init_manuals {
|
||||
project=$1
|
||||
|
@ -20,10 +20,11 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
DJANGO_PROJECT_SUFFIXES = ('-dashboard',
|
||||
'-horizon',
|
||||
'-ui',
|
||||
'django_openstack_auth',
|
||||
DJANGO_PROJECT_SUFFIXES = (
|
||||
'-dashboard',
|
||||
'horizon', # to match horizon and *-horizon
|
||||
'-ui',
|
||||
'django_openstack_auth',
|
||||
)
|
||||
|
||||
|
||||
@ -100,13 +101,13 @@ def main():
|
||||
|
||||
if 'openstack_translations' in config:
|
||||
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)
|
||||
|
||||
# A shortest module name is selected now.
|
||||
if modules:
|
||||
print(sorted(modules, key=len)[0])
|
||||
print(' '.join(modules))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -74,11 +74,7 @@ function propose_training_guides {
|
||||
|
||||
# Propose updates for python projects
|
||||
function propose_python {
|
||||
local project=$1
|
||||
local modulename=$2
|
||||
|
||||
# Pull updated translations from Zanata
|
||||
pull_from_zanata "$project"
|
||||
local modulename=$1
|
||||
|
||||
# Extract all messages from project, including log messages.
|
||||
extract_messages "$modulename"
|
||||
@ -102,29 +98,9 @@ function propose_python {
|
||||
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
|
||||
function propose_django {
|
||||
local project=$1
|
||||
local modulename=$2
|
||||
# Pull updated translations from Zanata.
|
||||
pull_from_zanata "$project"
|
||||
local modulename=$1
|
||||
|
||||
# Update the .pot file
|
||||
extract_messages_django "$modulename"
|
||||
@ -152,25 +128,29 @@ case "$PROJECT" in
|
||||
setup_training_guides "$ZANATA_VERSION"
|
||||
propose_training_guides
|
||||
;;
|
||||
horizon)
|
||||
setup_horizon "$ZANATA_VERSION"
|
||||
propose_horizon
|
||||
;;
|
||||
*)
|
||||
# Common setup for python and django repositories
|
||||
# ---- Python projects ----
|
||||
MODULENAME=$(get_modulename $PROJECT python)
|
||||
if [ -n "$MODULENAME" ]; then
|
||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
||||
module_names=$(get_modulename $PROJECT python)
|
||||
if [ -n "$module_names" ]; then
|
||||
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||
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
|
||||
|
||||
# ---- Django projects ----
|
||||
MODULENAME=$(get_modulename $PROJECT django)
|
||||
if [ -n "$MODULENAME" ]; then
|
||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
||||
propose_django "$PROJECT" "$MODULENAME"
|
||||
module_names=$(get_modulename $PROJECT django)
|
||||
if [ -n "$module_names" ]; then
|
||||
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||
# Pull updated translations from Zanata.
|
||||
pull_from_zanata "$PROJECT"
|
||||
for modulename in $module_names; do
|
||||
propose_django "$modulename"
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
@ -40,26 +40,26 @@ case "$PROJECT" in
|
||||
training-guides)
|
||||
setup_training_guides "$ZANATA_VERSION"
|
||||
;;
|
||||
horizon)
|
||||
setup_horizon "$ZANATA_VERSION"
|
||||
./run_tests.sh --makemessages -V
|
||||
;;
|
||||
*)
|
||||
# Common setup for python and django repositories
|
||||
# ---- Python projects ----
|
||||
MODULENAME=$(get_modulename $PROJECT python)
|
||||
if [ -n "$MODULENAME" ]; then
|
||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
||||
module_names=$(get_modulename $PROJECT python)
|
||||
if [ -n "$module_names" ]; then
|
||||
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||
setup_loglevel_vars
|
||||
extract_messages "$MODULENAME"
|
||||
extract_messages_log "$MODULENAME"
|
||||
for modulename in $module_names; do
|
||||
extract_messages "$modulename"
|
||||
extract_messages_log "$modulename"
|
||||
done
|
||||
fi
|
||||
|
||||
# ---- Django projects ----
|
||||
MODULENAME=$(get_modulename $PROJECT django)
|
||||
if [ -n "$MODULENAME" ]; then
|
||||
setup_project "$PROJECT" "$MODULENAME" "$ZANATA_VERSION"
|
||||
extract_messages_django "$MODULENAME"
|
||||
module_names=$(get_modulename $PROJECT django)
|
||||
if [ -n "$module_names" ]; then
|
||||
setup_project "$PROJECT" "$ZANATA_VERSION" $module_names
|
||||
for modulename in $module_names; do
|
||||
extract_messages_django "$modulename"
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user