diff --git a/xwords4/android/scripts/strings_check.sh b/xwords4/android/scripts/strings_check.sh index 574a110df..3f44f4b74 100755 --- a/xwords4/android/scripts/strings_check.sh +++ b/xwords4/android/scripts/strings_check.sh @@ -4,18 +4,25 @@ set -u -e declare -A ENG_IDS LOCS="" +LIST_ONLY="" +PAIRS_ONLY="" SEARCH_SOURCE=1 -ENG=~/dev/git/ANDROID_BRANCH/xwords4/android/XWords4/res/values/strings.xml +# ENG=~/dev/git/ANDROID_BRANCH/xwords4/android/XWords4/res/values/strings.xml usage() { - echo "usage: $0 [--loc ]*" >&2 + echo "usage: $0 (--loc )+ [--list-only] [--pairs-only]" >&2 exit 1 } list_ids() { XML_FILE=$1 - xmlstarlet sel -T -t -m "/resources/string" -v @name -o " " $XML_FILE + xmlstarlet sel -T -t -m "/resources/string" -v @name -n $XML_FILE +} + +list_pairs() { + XML_FILE=$1 + xmlstarlet sel -T -t -m "/resources/string" -v "concat(.,'|')" -n $XML_FILE } while [ $# -gt 0 ]; do @@ -26,6 +33,12 @@ while [ $# -gt 0 ]; do LOCS="$LOCS $2" shift ;; + --list-only) + LIST_ONLY=1 + ;; + --pairs-only) + PAIRS_ONLY=1 + ;; *) usage ;; @@ -33,9 +46,27 @@ while [ $# -gt 0 ]; do shift done +[ -n "$LOCS" ] || usage + +if [ -n "$LIST_ONLY" ]; then + for LOC in $LOCS; do + list_ids $LOC + done + exit 0 +fi + +if [ -n "$PAIRS_ONLY" ]; then + for LOC in $LOCS; do + list_pairs $LOC + done + exit 0 +fi + # echo "checking $ENG for ids not in any .java file" -for ID in $(list_ids $ENG); do - ENG_IDS[$ID]=1 +for LOC in $LOCS; do + for ID in $(list_ids $LOC); do + ENG_IDS[$ID]=1 + done done if [ -n "$SEARCH_SOURCE" ]; then