Blame translation-canary/xgettext_werror.sh

Packit b040ce
#!/bin/sh -e
Packit b040ce
#
Packit b040ce
# xgettext_werror.sh: Run xgettext and actually do something with the warnings
Packit b040ce
#
Packit b040ce
# xgettext prints out warnings for certain problems in translatable strings,
Packit b040ce
# such as format strings that cannot be translated due to position-based
Packit b040ce
# parameters. These warnings generally indicate something that needs to be
Packit b040ce
# addressed before the strings can be submitted for translation. This script
Packit b040ce
# exits with a status of 1 so that the warnings are not ignored as they scroll
Packit b040ce
# by in pages of build output.
Packit b040ce
#
Packit b040ce
# This script should be used in place of xgettext when rebuilding the .pot file,
Packit b040ce
# e.g. by setting XGETTEXT in po/Makevars.
Packit b040ce
#
Packit b040ce
# Copyright (C) 2015  Red Hat, Inc.
Packit b040ce
#
Packit b040ce
# This copyrighted material is made available to anyone wishing to use,
Packit b040ce
# modify, copy, or redistribute it subject to the terms and conditions of
Packit b040ce
# the GNU Lesser General Public License v.2, or (at your option) any later
Packit b040ce
# version. This program is distributed in the hope that it will be useful,
Packit b040ce
# but WITHOUT ANY WARRANTY expressed or implied, including the implied
Packit b040ce
# warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
Packit b040ce
# the GNU Lesser General Public License for more details.  You should have
Packit b040ce
# received a copy of the GNU Lesser General Public License along with this
Packit b040ce
# program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Packit b040ce
# Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat trademarks
Packit b040ce
# that are incorporated in the source code or documentation are not subject
Packit b040ce
# to the GNU Lesser General Public License and may only be used or
Packit b040ce
# replicated with the express permission of Red Hat, Inc.
Packit b040ce
#
Packit b040ce
# Red Hat Author(s): David Shea <dshea@redhat.com>
Packit b040ce
Packit b040ce
returncode=0
Packit b040ce
Packit b040ce
# Collect the output from xgettext. If xgettext fails, treat that as a failure
Packit b040ce
# Make sure that "warning:" doesn't get translated
Packit b040ce
xgettext_output="$(LC_MESSAGES=C xgettext "$@" 2>&1)" || returncode=$?
Packit b040ce
Packit b040ce
# Look for warnings
Packit b040ce
if echo "$xgettext_output" | fgrep -q "warning: "; then
Packit b040ce
    returncode=1
Packit b040ce
fi
Packit b040ce
Packit b040ce
# Print the output and return
Packit b040ce
echo "$xgettext_output"
Packit b040ce
exit $returncode