Two small fixes to generateUnusedKeys: numbering and flow
This commit is contained in:
@@ -117,45 +117,46 @@ if [[ $REPLY = y || $REPLY = Y ]]; then
|
||||
ttot=$((ttot2-ttot1))
|
||||
tsec=$((ttot%60))
|
||||
tmin=$((ttot/60))
|
||||
printf '%s\n' "Finished updating ${#langFiles[@]} files." "Total time: ${tmin}m ${tsec}s" ""
|
||||
|
||||
printf '%s\n' "The above cleaned up \"default\" from keys not found in the code and then it removed the same keys from the translation files. However if the translation files contain keys which were not in \"default\" then they would remain (because it would take too long to scan the source code for each key in each translation). Since at this point \"default\" is good as gold, it's most time efficient then to match each interface translation file against it and remove all keys not found in it." "" | fold -s
|
||||
read -r -p "Match ${#langFiles[@]} interface translation files against \"default\" and delete unmatched keys? [y/n] "
|
||||
if [[ $REPLY = y || $REPLY = Y ]]; then
|
||||
printf '%s\n' "Removing keys from:"
|
||||
i=1
|
||||
ttot1="$(date +%s)"
|
||||
for file in "${langFiles[@]}"; do
|
||||
printf "%02d - ${file#.*/}" "$i"
|
||||
t1="$(date +%s)"
|
||||
unset delLines
|
||||
# Read line by line
|
||||
while read -r line; do
|
||||
# If line starts with a real key, not a comment or empty line
|
||||
if [[ $line =~ ^[A-Z0-9_]+\; ]]; then
|
||||
# then get the key part
|
||||
key="${line%%;*}"
|
||||
# quietly check whether it exists in default
|
||||
grep -Irq "$key" default
|
||||
# and if match fails, put it on the kill list
|
||||
if [[ $? = 1 ]]; then
|
||||
delLines+=("${key}")
|
||||
fi
|
||||
fi
|
||||
done < "$file"
|
||||
# kill szeva
|
||||
for key in "${delLines[@]}"; do
|
||||
sed -i "/.\?$key/d" "$file"
|
||||
done
|
||||
t2="$(date +%s)"
|
||||
tt=$((t2-t1))
|
||||
printf '%s\n' " - took $tt seconds"
|
||||
done
|
||||
ttot2="$(date +%s)"
|
||||
ttot=$((ttot2-ttot1))
|
||||
tsec=$((ttot%60))
|
||||
tmin=$((ttot/60))
|
||||
printf '%s\n' "Finished updating ${#langFiles[@]} files." "Total time: ${tmin}m ${tsec}s"
|
||||
fi
|
||||
|
||||
printf '%s\n' "Finished updating ${#langFiles[@]} files." "Total time: ${tmin}m ${tsec}s"
|
||||
fi
|
||||
|
||||
printf '%s\n' "" "The above cleaned up \"default\" from keys not found in the code and then it removed the same keys from the translation files. However if the translation files contain keys which were not in \"default\" then they would remain (because it would take too long to scan the source code for each key in each translation). Since at this point \"default\" is good as gold, it's most time efficient then to match each interface translation file against it and remove all keys not found in it." "" | fold -s
|
||||
read -r -p "Match ${#langFiles[@]} interface translation files against \"default\" and delete unmatched keys? [y/n] "
|
||||
if [[ $REPLY = y || $REPLY = Y ]]; then
|
||||
printf '%s\n' "Removing keys from:"
|
||||
i=1
|
||||
ttot1="$(date +%s)"
|
||||
for file in "${langFiles[@]}"; do
|
||||
printf "%02d - ${file#.*/}" "$i"
|
||||
t1="$(date +%s)"
|
||||
unset delLines
|
||||
# Read line by line
|
||||
while read -r line; do
|
||||
# If line starts with a real key, not a comment or empty line
|
||||
if [[ $line =~ ^[A-Z0-9_]+\; ]]; then
|
||||
# then get the key part
|
||||
key="${line%%;*}"
|
||||
# quietly check whether it exists in default
|
||||
grep -Irq "$key" default
|
||||
# and if match fails, put it on the kill list
|
||||
if [[ $? = 1 ]]; then
|
||||
delLines+=("${key}")
|
||||
fi
|
||||
fi
|
||||
done < "$file"
|
||||
# kill szeva
|
||||
for key in "${delLines[@]}"; do
|
||||
sed -i "/.\?$key/d" "$file"
|
||||
done
|
||||
t2="$(date +%s)"
|
||||
tt=$((t2-t1))
|
||||
printf '%s\n' " - took $tt seconds"
|
||||
((i++))
|
||||
done
|
||||
ttot2="$(date +%s)"
|
||||
ttot=$((ttot2-ttot1))
|
||||
tsec=$((ttot%60))
|
||||
tmin=$((ttot/60))
|
||||
printf '%s\n' "Finished updating ${#langFiles[@]} files." "Total time: ${tmin}m ${tsec}s"
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user