Marlin_Firmware/buildroot/share/scripts/findMissingTranslations.sh

48 lines
1.3 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
#
# findMissingTranslations.sh
#
# Locate all language strings needing an update based on English
#
# Usage: findMissingTranslations.sh [language codes]
#
# If no language codes are specified then all languages will be checked
#
LANGHOME="Marlin/src/lcd/language"
[ -d $LANGHOME ] && cd $LANGHOME
2021-09-19 18:40:56 -05:00
FILES=$(ls language_*.h | grep -v -E "(_en|_test)\.h" | sed -E 's/language_([^\.]+)\.h/\1/' | tr '\n' ' ')
2016-12-06 22:48:26 -06:00
# Get files matching the given arguments
2021-09-19 18:40:56 -05:00
TEST_LANGS=""
2016-12-06 22:48:26 -06:00
if [[ -n $@ ]]; then
for K in "$@"; do
for F in $FILES; do
2021-09-19 18:40:56 -05:00
[[ "$F" != "${F%$K*}" ]] && TEST_LANGS+="$F "
2016-12-06 22:48:26 -06:00
done
done
2021-09-19 18:40:56 -05:00
[[ -z $TEST_LANGS ]] && { echo "No languages matching $@." ; exit 0 ; }
else
TEST_LANGS=$FILES
2016-12-06 22:48:26 -06:00
fi
2021-09-19 18:40:56 -05:00
echo "Missing strings for $TEST_LANGS..."
2021-09-19 18:40:56 -05:00
for WORD in $(awk '/LSTR/{print $2}' language_en.h); do
2021-09-19 19:25:01 -05:00
[[ $WORD == "MSG_MARLIN" ]] && break
LANG_LIST=""
2021-09-19 18:40:56 -05:00
for LANG in $TEST_LANGS; do
if [[ $(grep -c -E "^ *LSTR +$WORD\b" language_${LANG}.h) -eq 0 ]]; then
INHERIT=$(awk '/using namespace/{print $3}' language_${LANG}.h | sed -E 's/Language_([a-zA-Z_]+)\s*;/\1/')
if [[ -z $INHERIT || $INHERIT == "en" ]]; then
LANG_LIST+=" $LANG"
elif [[ $(grep -c -E "^ *LSTR +$WORD\b" language_${INHERIT}.h) -eq 0 ]]; then
LANG_LIST+=" $LANG"
fi
fi
done
2021-09-19 18:40:56 -05:00
[[ -n $LANG_LIST ]] && printf "%-38s :%s\n" "$WORD" "$LANG_LIST"
done