Created
September 5, 2016 03:23
-
-
Save satanasov/3b616b7283dc73f3296b03524778e9e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A quick script to check language usage in phpBB extension | |
# Author: Stanislav Atanasov ([email protected] | |
# Script provided as is! | |
VARIABLES=( "$@" ) | |
LANG_FILE='' | |
TARGET_EXT='' | |
FULL=0 | |
count=0 | |
while [ "x${VARIABLES[count]}" != x ]; do | |
if [[ ${VARIABLES[count]} == "-l" ]] || [[ ${VARIABLES[count]} == "--language" ]]; then | |
count=$(( $count + 1 )) | |
LANG_FILE=${VARIABLES[count]} | |
count=$(( $count + 1)) | |
elif [[ ${VARIABLES[count]} == "-t" ]] || [[ ${VARIABLES[count]} == "--target" ]]; then | |
count=$(( $count + 1 )) | |
TARGET_EXT=${VARIABLES[count]} | |
count=$(( $count + 1)) | |
elif [[ ${VARIABLES[count]} == "-f" ]] || [[ ${VARIABLES[count]} == "--full" ]]; then | |
count=$(( $count + 1 )) | |
FULL=1 | |
fi | |
done | |
if [[ ! $LANG_FILE ]] || [[ ! $TARGET_EXT ]]; then | |
printf "Usage: | |
-l, --language {TARGET} - Select desired language file | |
-t, --target {EXT} - Select the target extension directory | |
-f - Show full report where the language variables are used | |
WARNING: The script will use the target for building the report and will skip language folder \n" | |
elif [[ ! -e $LANG_FILE ]]; then | |
printf "Language file $LANG_FILE doesn't exist. Please check again!\n" | |
elif [[ ! -d $TARGET_EXT ]]; then | |
printf "Extension $TARGET_EXT doesn't exist. Please check again!\n" | |
else | |
while read -r line || [[ -n "$line" ]]; do | |
fstr=`echo $line| cut -c1` | |
if [[ $fstr ]] && [[ $fstr == *"'"* ]]; then | |
str=`echo $line | awk '{print $1}'` | |
if [[ $FULL == 1 ]]; then | |
echo $str | |
grep -Rni --exclude-dir=language "$str" $TARGET_EXT | |
else | |
count=`grep -Rni --exclude-dir=language "$str" $TARGET_EXT | wc -l` | |
echo "$str -> $(($count))" | |
fi | |
fi | |
done < "$LANG_FILE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment