1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 22:08:02 +00:00
MarlinFirmware/buildroot/share/scripts/findMissingTranslations.sh

48 lines
1.3 KiB
Bash
Raw 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 23:40:56 +00:00
FILES=$(ls language_*.h | grep -v -E "(_en|_test)\.h" | sed -E 's/language_([^\.]+)\.h/\1/' | tr '\n' ' ')
2016-12-07 04:48:26 +00:00
# Get files matching the given arguments
2021-09-19 23:40:56 +00:00
TEST_LANGS=""
2016-12-07 04:48:26 +00:00
if [[ -n $@ ]]; then
for K in "$@"; do
for F in $FILES; do
2021-09-19 23:40:56 +00:00
[[ "$F" != "${F%$K*}" ]] && TEST_LANGS+="$F "
2016-12-07 04:48:26 +00:00
done
done
2021-09-19 23:40:56 +00:00
[[ -z $TEST_LANGS ]] && { echo "No languages matching $@." ; exit 0 ; }
else
TEST_LANGS=$FILES
2016-12-07 04:48:26 +00:00
fi
2021-09-19 23:40:56 +00:00
echo "Missing strings for $TEST_LANGS..."
2021-09-19 23:40:56 +00:00
for WORD in $(awk '/LSTR/{print $2}' language_en.h); do
2021-09-20 00:25:01 +00:00
[[ $WORD == "MSG_MARLIN" ]] && break
LANG_LIST=""
2021-09-19 23:40:56 +00: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 23:40:56 +00:00
[[ -n $LANG_LIST ]] && printf "%-38s :%s\n" "$WORD" "$LANG_LIST"
done