Merge pull request #19552 from kamil-tekiela/Fix-default-values
[phpmyadmin.git] / bin / internal / lang-cleanup.sh
blobc85ecf768b6d8e7e7a6ac914b512efb2301fd8ca
1 #!/bin/sh
3 # vim: expandtab sw=4 ts=4 sts=4:
5 # Script for removing language selection from phpMyAdmin
7 # Do not run as CGI
8 if [ -n "$GATEWAY_INTERFACE" ] ; then
9 echo 'Can not invoke as CGI!'
10 exit 1
13 if [ $# -lt 1 ] ; then
14 echo "Usage: lang-cleanup.sh type"
15 echo "Type can be one of:"
16 echo " all-languages - nothing will be done"
17 echo " source - nothing will be done"
18 echo " english - no translations will be kept"
19 echo " langcode - keeps language"
20 echo
21 echo "Languages can be specified multiple times"
22 exit 1
25 # Expression for find
26 match=""
27 for type in "$@" ; do
28 case $type in
29 all-languages|source)
30 exit 0
32 english)
33 rm -rf resources/po
34 rm -rf resources/locale
35 rm -rf vendor/phpmyadmin/sql-parser/locale
36 exit 0
39 match="$match -and -not -name $type.po -and -not -path resources/locale/$type/LC_MESSAGES/phpmyadmin.mo -and -not -path vendor/phpmyadmin/sql-parser/locale/$type/LC_MESSAGES/sqlparser.mo"
41 esac
42 done
44 # Delete unwanted languages
45 # shellcheck disable=SC2086
46 find resources/po resources/locale vendor/phpmyadmin/sql-parser/locale -type f $match -print0 | xargs -0r rm
48 # Delete empty directories
49 rmdir --ignore-fail-on-non-empty resources/locale/*/*
50 rmdir --ignore-fail-on-non-empty resources/locale/*
51 rmdir --ignore-fail-on-non-empty vendor/phpmyadmin/sql-parser/locale/*/*
52 rmdir --ignore-fail-on-non-empty vendor/phpmyadmin/sql-parser/locale/*