Updated generateUnusedKeys
This commit is contained in:
@@ -1,20 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This script is part of RawTherapee.
|
||||||
|
#
|
||||||
# This Bash4 script checks whether each key in "default" is used in
|
# This Bash4 script checks whether each key in "default" is used in
|
||||||
# a .cc or .h file. Those that are not are printed to screen, and the
|
# a .cc or .h file. Those that are not are printed to screen, and the
|
||||||
# user is asked if they should be deleted from all language files.
|
# user is asked if they should be deleted from all language files.
|
||||||
#
|
#
|
||||||
# Keys in commented-out sections are treated as if they weren't there.
|
# Keys in commented-out sections "//" are ignored.
|
||||||
# The following comment styles are handled:
|
#
|
||||||
# // key
|
# Some concatenated keys are ignored, these need to be added to the list manually:
|
||||||
# /* key
|
|
||||||
# key */
|
|
||||||
|
|
||||||
# It does not handle dynamically built keys:
|
|
||||||
# HISTORY_MSG_
|
# HISTORY_MSG_
|
||||||
# EXTPROGTARGET_
|
# EXTPROGTARGET_
|
||||||
# FILEBROWSER_POPUPRANK
|
# FILEBROWSER_POPUPRANK
|
||||||
# FILEBROWSER_POPUPCOLORLABEL
|
# FILEBROWSER_POPUPCOLORLABEL
|
||||||
|
# SAMPLEFORMAT_
|
||||||
|
# TP_RAW_[demosaic_method]
|
||||||
#
|
#
|
||||||
# The script can also clean up already-translated files by removing keys which
|
# The script can also clean up already-translated files by removing keys which
|
||||||
# do not exist in default.
|
# do not exist in default.
|
||||||
@@ -22,11 +22,10 @@
|
|||||||
# Run the script from the project root:
|
# Run the script from the project root:
|
||||||
# ./tools/generateUnusedKeys
|
# ./tools/generateUnusedKeys
|
||||||
#
|
#
|
||||||
# Doublecheck the deletion before committing.
|
|
||||||
# Run ./tools/generateTranslationDiffs before and after running this script.
|
# Run ./tools/generateTranslationDiffs before and after running this script.
|
||||||
|
# Double-check the deletion before committing.
|
||||||
#
|
#
|
||||||
# Blame DrSlony
|
# Blame DrSlony
|
||||||
# Please report bugs or enhancements to http://code.google.com/p/rawtherapee/issues/list
|
|
||||||
|
|
||||||
tmp=temp_file
|
tmp=temp_file
|
||||||
if [[ -w $tmp ]]; then
|
if [[ -w $tmp ]]; then
|
||||||
@@ -61,26 +60,41 @@ fi
|
|||||||
|
|
||||||
dos2unix default 2>/dev/null
|
dos2unix default 2>/dev/null
|
||||||
|
|
||||||
|
# In the code block below, the grep/sed outside the loop lists keys to ignore.
|
||||||
|
# Exit status 1 (failure) means key not found in code, destined for deletion.
|
||||||
|
# The piped grep inside the loop checks the initial match for known comment markers "//".
|
||||||
|
# Sometimes a key is first found in a comment, and then the same key is found
|
||||||
|
# in active code, therefore -m1 (stop reading after 1st match) cannot be used.
|
||||||
|
# To remove comment support, remove the piped grep and set first grep flags to
|
||||||
|
# -Irl -m1
|
||||||
|
# Dynamically built keys like HISTORY_MSG_1 can't be grepped in the code,
|
||||||
|
# so it renames KEY_1-KEY_9 to KEY_ so that they can be grepped and therefore ignored.
|
||||||
t1="$(date +%s)"
|
t1="$(date +%s)"
|
||||||
printf '%s\n' 'Matching keys in "default" against .cc and .h files' 'Unmatched keys follow:'
|
printf '%s\n' 'Matching keys in "default" against .cc and .h files' 'Unmatched keys follow:'
|
||||||
unset delLines
|
unset delLines
|
||||||
while read -r 'defLine'; do
|
while read -r 'defLine'; do
|
||||||
grep -Ir --include=\*.{cc,h} --exclude-dir="klt" "${defLine%%;*}" ../../* | grep -Ev "//.*${defLine%%;*}|/\*.*${defLine%%;*}|${defLine%%;*}.*\*/" &>/dev/null
|
grep -Ir --include=\*.{cc,h} --exclude-dir="klt" "${defLine%%;*}" ../../* | grep -Ev "//.*${defLine%%;*}" &>/dev/null
|
||||||
if [[ $? = 1 ]]; then
|
if [[ $? = 1 ]]; then
|
||||||
printf ' %s\n' "${defLine%%;*}"
|
printf ' %s\n' "${defLine%%;*}"
|
||||||
delLines+=("${defLine%%;*}")
|
delLines+=("${defLine%%;*}")
|
||||||
fi
|
fi
|
||||||
done < <(grep -Ev "^(#|$)|HISTORY_MSG_" "default" | sed -e "s/EXTPROGTARGET_[0-9]*/EXTPROGTARGET_/" -e "s/FILEBROWSER_POPUPCOLORLABEL[0-9]*/FILEBROWSER_POPUPCOLORLABEL/" -e "s/FILEBROWSER_POPUPRANK[0-9]*/FILEBROWSER_POPUPRANK/" | sort -Vu)
|
done < <( \
|
||||||
# The grep/sed line above lists keys to ignore. Exit status 1 (failure) means
|
grep -Ev -e "^(#|$)|HISTORY_MSG_" \
|
||||||
# key not found in code, destined for deletion. The piped grep in the loop
|
-e "^(#|$)|TP_RAW_1PASSMEDIUM" \
|
||||||
# checks the initial match for known comment markers // /* and */
|
-e "^(#|$)|TP_RAW_2PASS" \
|
||||||
# Sometimes a key is first found in a comment, and then the same key is found
|
-e "^(#|$)|TP_RAW_3PASSBEST" \
|
||||||
# in active code, therefore -m1 (stop reading after 1st match) cannot be used.
|
-e "^(#|$)|TP_RAW_4PASS" \
|
||||||
# To remove comment support, remove the piped grep and set first grep flags to
|
-e "^(#|$)|TP_RAW_AMAZEVNG4" \
|
||||||
# -Irl -m1
|
-e "^(#|$)|TP_RAW_DCBVNG4" \
|
||||||
# Dynamically built keys like HISTORY_MSG_1 can't be grepped in the code,
|
-e "^(#|$)|TP_RAW_MONO" \
|
||||||
# so it renames KEY_1-KEY_9 to KEY_ so that they can be grepped and therefore ignored.
|
-e "^(#|$)|TP_RAW_NONE" \
|
||||||
# The piped grep in the loop
|
-e "^(#|$)|TP_RAW_RCDVNG4" \
|
||||||
|
"default" | \
|
||||||
|
sed -e "s/EXTPROGTARGET_[0-9]*/EXTPROGTARGET_/" \
|
||||||
|
-e "s/FILEBROWSER_POPUPCOLORLABEL[0-9]*/FILEBROWSER_POPUPCOLORLABEL/" \
|
||||||
|
-e "s/FILEBROWSER_POPUPRANK[0-9]*/FILEBROWSER_POPUPRANK/" \
|
||||||
|
-e "s/SAMPLEFORMAT_[0-9]*/SAMPLEFORMAT_/" \
|
||||||
|
| sort -Vu)
|
||||||
t2="$(date +%s)"
|
t2="$(date +%s)"
|
||||||
tt=$((t2-t1))
|
tt=$((t2-t1))
|
||||||
printf '%s\n' "" "Scan took $tt seconds" "" "Double-checking the code for matched keys:"
|
printf '%s\n' "" "Scan took $tt seconds" "" "Double-checking the code for matched keys:"
|
||||||
|
Reference in New Issue
Block a user