2014-04-22 22:16:18 +00:00
|
|
|
#!/bin/bash -xe
|
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2014-07-10 17:22:40 +00:00
|
|
|
PROJECT=$1
|
2015-08-06 07:11:30 +00:00
|
|
|
SOFTWARE="Transifex"
|
|
|
|
|
|
|
|
if [ -n "$2" -a "$2" = "zanata" ]; then
|
|
|
|
SOFTWARE="Zanata"
|
|
|
|
fi
|
2014-04-22 22:16:18 +00:00
|
|
|
|
2014-05-24 18:23:05 +00:00
|
|
|
source /usr/local/jenkins/slave_scripts/common_translation_update.sh
|
2014-04-22 22:16:18 +00:00
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Setup git repository for git review.
|
2014-05-24 18:23:05 +00:00
|
|
|
setup_git
|
2014-04-22 22:16:18 +00:00
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Check whether a review already exists, setup review commit message.
|
2015-08-06 07:11:30 +00:00
|
|
|
setup_review "$SOFTWARE"
|
2014-10-07 14:47:56 +00:00
|
|
|
# Setup basic connection for transifex.
|
2014-05-24 18:23:05 +00:00
|
|
|
setup_translation
|
2014-10-07 14:47:56 +00:00
|
|
|
# Project specific transifex setup.
|
2014-05-24 18:23:05 +00:00
|
|
|
setup_project "$PROJECT"
|
2014-04-22 22:16:18 +00:00
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Setup some global vars which will be used in the rest of the script.
|
2014-05-24 18:12:35 +00:00
|
|
|
setup_loglevel_vars
|
2014-10-07 14:47:56 +00:00
|
|
|
# Project specific transifex setup for log translations.
|
2014-05-24 18:12:35 +00:00
|
|
|
setup_loglevel_project "$PROJECT"
|
|
|
|
|
2015-08-06 07:11:30 +00:00
|
|
|
# Pull updated translations from Transifex, or Zanata.
|
|
|
|
case "$SOFTWARE" in
|
|
|
|
Transifex)
|
|
|
|
pull_from_transifex
|
|
|
|
;;
|
|
|
|
Zanata)
|
2015-09-03 02:56:24 +00:00
|
|
|
pull_from_zanata
|
2015-08-06 07:11:30 +00:00
|
|
|
;;
|
|
|
|
esac
|
2014-10-15 08:43:10 +00:00
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Extract all messages from project, including log messages.
|
2014-05-24 18:12:35 +00:00
|
|
|
extract_messages_log "$PROJECT"
|
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Update existing translation files with extracted messages.
|
2015-06-04 05:33:48 +00:00
|
|
|
PO_FILES=$(find ${PROJECT}/locale -name "${PROJECT}.po")
|
2014-09-29 20:28:19 +00:00
|
|
|
if [ -n "$PO_FILES" ]; then
|
2014-04-22 22:16:18 +00:00
|
|
|
# Use updated .pot file to update translations
|
2015-05-03 07:55:00 +00:00
|
|
|
python setup.py $QUIET update_catalog \
|
|
|
|
--no-fuzzy-matching --ignore-obsolete=true
|
2014-04-22 22:16:18 +00:00
|
|
|
fi
|
2014-10-07 14:47:56 +00:00
|
|
|
# We cannot run update_catalog for the log files, since there is no
|
2014-05-24 18:12:35 +00:00
|
|
|
# option to specify the keyword and thus an update_catalog run would
|
|
|
|
# add the messages with the default keywords. Therefore use msgmerge
|
|
|
|
# directly.
|
|
|
|
for level in $LEVELS ; do
|
2015-06-04 05:33:48 +00:00
|
|
|
PO_FILES=$(find ${PROJECT}/locale -name "${PROJECT}-log-${level}.po")
|
2014-09-29 20:28:19 +00:00
|
|
|
if [ -n "$PO_FILES" ]; then
|
|
|
|
for f in $PO_FILES ; do
|
|
|
|
echo "Updating $f"
|
|
|
|
msgmerge --update --no-fuzzy-matching $f \
|
|
|
|
--backup=none \
|
|
|
|
${PROJECT}/locale/${PROJECT}-log-${level}.pot
|
|
|
|
# Remove obsolete entries
|
|
|
|
msgattrib --no-obsolete --force-po \
|
|
|
|
--output-file=${f}.tmp ${f}
|
|
|
|
mv ${f}.tmp ${f}
|
|
|
|
done
|
|
|
|
fi
|
2014-05-24 18:12:35 +00:00
|
|
|
done
|
|
|
|
|
2015-05-02 06:29:37 +00:00
|
|
|
# Now add all changed files to git.
|
|
|
|
# Note we add them here to not have to differentiate in the functions
|
|
|
|
# between new files and files already under git control.
|
|
|
|
git add $PROJECT/locale/*
|
2014-04-22 22:16:18 +00:00
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Remove obsolete files.
|
2014-09-26 00:00:44 +00:00
|
|
|
cleanup_po_files "$PROJECT"
|
2014-10-07 14:47:56 +00:00
|
|
|
|
2015-04-23 19:22:59 +00:00
|
|
|
# Compress downloaded po files, this needs to be done after
|
|
|
|
# cleanup_po_files since that function needs to have information the
|
|
|
|
# number of untranslated strings.
|
|
|
|
compress_po_files "$PROJECT"
|
|
|
|
|
2015-05-03 07:41:04 +00:00
|
|
|
# Some files were changed, add changed files again to git, so that we
|
|
|
|
# can run git diff properly.
|
2015-04-23 19:22:59 +00:00
|
|
|
git add $PROJECT/locale/*
|
|
|
|
|
2015-05-03 07:41:04 +00:00
|
|
|
# Filter out commits we do not want.
|
|
|
|
filter_commits
|
|
|
|
|
2014-10-07 14:47:56 +00:00
|
|
|
# Propose patch to gerrit if there are changes.
|
2014-05-24 18:23:05 +00:00
|
|
|
send_patch
|