diff --git a/po/Makefile b/po/Makefile index fa6dd0a15b9..ad5bf82e069 100644 --- a/po/Makefile +++ b/po/Makefile @@ -18,19 +18,6 @@ GIT_LS_JS:=git ls-files -- \ ':(top,glob,exclude)root/statistics/**/*.js' \ | $(SED_ESCAPE_SPACES) -GIT_LS_ADMINPERL:=git ls-files -- \ - ':(top,glob)lib/**/*Admin*.pm' \ - ':(top,glob)lib/**/*Admin*/**/*.pm' \ - | $(SED_ESCAPE_SPACES) - -GIT_LS_ADMINTT:=git ls-files -- \ - ':(top,glob)root/admin/**/*.tt' \ - | $(SED_ESCAPE_SPACES) - -GIT_LS_ADMINJS:=git ls-files -- \ - ':(top,glob)root/admin/**/*.js' \ - | $(SED_ESCAPE_SPACES) - GIT_LS_TT:=git ls-files -- \ ':(top,glob)root/**/*.tt' \ ':(top,glob,exclude)root/admin/**/*.tt' \ @@ -48,9 +35,6 @@ GIT_LS_STATJS:=git ls-files -- \ POTFILES=$(shell $(GIT_LS_PERL)) JSFILES=$(shell $(GIT_LS_JS)) TT=$(shell $(GIT_LS_TT)) -ADMINPERL=$(shell $(GIT_LS_ADMINPERL)) -ADMINTT=$(shell $(GIT_LS_ADMINTT)) -ADMINJS=$(shell $(GIT_LS_ADMINJS)) STATTT=$(shell $(GIT_LS_STATTT)) STATJS=$(shell $(GIT_LS_STATJS)) @@ -159,37 +143,7 @@ check_quiet: msgfmt -o /dev/null -c $$file;\ done -test_source: test_no_admin - -test_no_admin: $(ADMINPERL) $(ADMINTT) $(ADMINJS) $(wildcard extract_pot_templates) - @echo "Testing that no admin files contain any translatable messages (MBS-13117)"; - @count=0; \ - for file in $(ADMINPERL); do \ - pot=`xgettext --from-code utf-8 --keyword=__ --keyword=l --keyword=lp:1,2c --keyword=N_lp:1,2c --keyword=N_l --keyword=ln:1,2 --keyword=N_ln:1,2 --keyword=__x --keyword=__nx:1,2 --keyword=__n:1,2 -Lperl -o - $$file`; \ - if [ -n "$$pot" ]; then \ - printf "$$pot" | grep '^#:'; \ - count=`expr $$count + 1`; \ - fi; \ - done; \ - for file in $(ADMINTT); do \ - pot=`./extract_pot_templates $$file`; \ - if [ -n "$$pot" ]; then \ - printf "$$pot" | grep '^#:'; \ - count=`expr $$count + 1`; \ - fi; \ - done; \ - for file in $(ADMINJS); do \ - pot=`../script/xgettext.js $$file`; \ - if [ -n "$$pot" ]; then \ - printf "$$pot" | grep '^#:'; \ - count=`expr $$count + 1`; \ - fi; \ - done; \ - if [ $$count -gt 0 ]; then \ - echo "Error: Found $$count admin files wrongly containing translatable messages"; \ - exit 1; \ - else \ - echo "OK"; \ - fi - -.PHONY: all all_quiet check check_quiet clean pot test_source test_no_admin +test_source: + @../t/no_gettext_for_admin.sh + +.PHONY: all all_quiet check check_quiet clean pot test_source diff --git a/t/no_gettext_for_admin.sh b/t/no_gettext_for_admin.sh new file mode 100755 index 00000000000..a86277cf786 --- /dev/null +++ b/t/no_gettext_for_admin.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +set -e -u + +SCRIPT_NAME=$(basename "$0") + +HELP=$(cat <&2 "$SCRIPT_NAME: too many arguments" + echo >&2 "$HELP" + exit 64 +elif [ $# -eq 1 ] +then + if echo "$1" | grep -Eqx -- '-*h(elp)?' + then + echo "$HELP" + exit + elif [ "$1" != '--commit' ] + then + echo >&2 "$SCRIPT_NAME: unrecognized option: $1" + echo >&2 "$HELP" + exit 64 + fi +fi + +MB_SERVER_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd) + +cd "$MB_SERVER_ROOT" + +echo "Testing that no admin files contain any translatable messages (MBS-13117)"; + +cd po + +function sed_escape_spaces() { + sed -e 's/ /\\ /g' +} + +declare -a admin_perl_files=( $(git ls-files -- \ + ':(top,glob)lib/**/*Admin*.pm' \ + ':(top,glob)lib/**/*Admin*/**/*.pm' \ + | sed_escape_spaces) ) + +declare -a admin_tt_files=( $(git ls-files -- \ + ':(top,glob)root/admin/**/*.tt' \ + | sed_escape_spaces) ) + +declare -a admin_js_files=( $(git ls-files -- \ + ':(top,glob)root/admin/**/*.js' \ + | sed_escape_spaces) ) + +declare count=0 + +for file in ${admin_perl_files[@]} +do + pot=`xgettext --from-code utf-8 --keyword=__ --keyword=l --keyword=lp:1,2c --keyword=N_lp:1,2c --keyword=N_l --keyword=ln:1,2 --keyword=N_ln:1,2 --keyword=__x --keyword=__nx:1,2 --keyword=__n:1,2 -Lperl -o - $file` + if [ -n "$pot" ] + then + printf "$pot" | grep '^#:' + count=`expr $count + 1` + fi +done + +for file in ${admin_tt_files[@]} +do + pot=`./extract_pot_templates $file | sed '1,10d'` + if [ -n "$pot" ] + then + printf "$pot" | grep '^#:' + count=`expr $count + 1` + fi +done + +for file in ${admin_js_files[@]} +do + pot=`../script/xgettext.js $file | sed '1,12d'` + if [ -n "$pot" ] + then + printf "$pot" | grep '^#:' + count=`expr $count + 1` + fi +done + +if [ $count -gt 0 ] +then + echo "Error: Found $count admin files wrongly containing translatable messages" + exit 1 +else + echo "OK" +fi + +# vi: set et sts=2 sw=2 ts=2 :