findMissingTranslations.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. #
  3. # findMissingTranslations.sh
  4. #
  5. # Locate all language strings needing an update based on English
  6. #
  7. # Usage: findMissingTranslations.sh [language codes]
  8. #
  9. # If no language codes are specified then all languages will be checked
  10. #
  11. LANGHOME="Marlin/src/lcd/language"
  12. [ -d $LANGHOME ] && cd $LANGHOME
  13. FILES=$(ls language_*.h | grep -v -E "(_en|_test)\.h" | sed -E 's/language_([^\.]+)\.h/\1/')
  14. declare -A STRING_MAP
  15. # Get files matching the given arguments
  16. TEST_LANGS=$FILES
  17. if [[ -n $@ ]]; then
  18. TEST_LANGS=""
  19. for K in "$@"; do
  20. for F in $FILES; do
  21. [[ "$F" != "${F%$K*}" ]] && TEST_LANGS="$TEST_LANGS $F"
  22. done
  23. done
  24. fi
  25. echo -n "Building list of missing strings..."
  26. for i in $(awk '/Language_Str/{print $3}' language_en.h); do
  27. [[ $i == "MSG_CUBED" ]] && continue
  28. LANG_LIST=""
  29. for j in $TEST_LANGS; do
  30. [[ $(grep -c " ${i} " language_${j}.h) -eq 0 ]] && LANG_LIST="$LANG_LIST $j"
  31. done
  32. [[ -z $LANG_LIST ]] && continue
  33. STRING_MAP[$i]=$LANG_LIST
  34. done
  35. echo
  36. for K in $( printf "%s\n" "${!STRING_MAP[@]}" | sort ); do
  37. case "$#" in
  38. 1 ) echo $K ;;
  39. * ) printf "%-35s :%s\n" "$K" "${STRING_MAP[$K]}" ;;
  40. esac
  41. done