phpmyadmin/scripts/update-po
Michal Čihař f2bfa7d745 Avoid running shell scripts as CGI
There is really no reason for that besides misconfigured servers.

This is followup for PMASA-2016-54

Signed-off-by: Michal Čihař <michal@cihar.com>
2016-12-08 11:41:42 +01:00

58 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# vim: expandtab sw=4 ts=4 sts=4:
export LC_ALL=C
# Do not run as CGI
if [ -n "$GATEWAY_INTERFACE" ] ; then
echo 'Can not invoke as CGI!'
exit 1
fi
# Exit on failure
set -e
# Update pot (template), ensure that advisor is at the end
LOCS=`ls po/*.po | sed 's@.*/\(.*\)\.po@\1@'`
xgettext \
-d phpmyadmin \
--msgid-bugs-address=translators@phpmyadmin.net \
-o po/phpmyadmin.pot \
--language=PHP \
--add-comments=l10n \
--add-location \
--debug \
--from-code=utf-8 \
--keyword=__ --keyword=_pgettext:1c,2 --keyword=_ngettext:1,2 \
--copyright-holder="phpMyAdmin devel team" \
`find -regex '.*\.\(php\|phtml\)$' -not -path './test/*' -not -path './po/*' -not -path './vendor/*' -not -path './release/*' | sort`
# Generate PHP code for advisor rules
php ./scripts/advisor2po >> po/phpmyadmin.pot
ver=`sed -n "/PMA_VERSION', '/ s/.*PMA_VERSION', '\(.*\)'.*/\1/p" libraries/Config.php`
sed -i '
s/SOME DESCRIPTIVE TITLE/phpMyAdmin translation/;
s/PACKAGE/phpMyAdmin/;
s/(C) YEAR/(C) 2003 - '`date +%Y`'/;
s/VERSION/'$ver'/;
' po/phpmyadmin.pot
# Update po files (translations)
for loc in $LOCS ; do
sed -i '
s/SOME DESCRIPTIVE TITLE/phpMyAdmin translation/;
s/PACKAGE/phpMyAdmin/;
s/(C) YEAR/(C) 2003 - '`date +%Y`'/;
s/VERSION/'$ver'/;
s/Project-Id-Version: phpMyAdmin .*/Project-Id-Version: phpMyAdmin '$ver'\\n"/;
' po/$loc.po
msgmerge --previous -U po/$loc.po po/phpmyadmin.pot
done
# Commit changes
git add po/*.po po/phpmyadmin.pot
git commit -s -m 'Update po files
[CI skip]'