Skip to content

Instantly share code, notes, and snippets.

@Toldy
Created October 11, 2016 22:14
Show Gist options
  • Save Toldy/3f25f17a52698b1e44ef222ecdcc0d85 to your computer and use it in GitHub Desktop.
Save Toldy/3f25f17a52698b1e44ef222ecdcc0d85 to your computer and use it in GitHub Desktop.
Scan a Localizable.string file and find its entries which are not used in the project
#!/bin/bash
# Before launching:
# - Copy the Base.lproj/Localizable.string to the same dir than this file
# - In the project Dir: Remove all strings files (rm -rf *.lproj)
# - Fill PROJECT_DIRECTORY
PROJECT_DIRECTORY=
echo "" > ./Localizable_results.txt
echo "" > ./Localizable_results_found.txt
echo "" > ./Localizable_results_not_found.txt
while read p; do # Get lines one by one
line=`echo "$p" | sed -e 's/ = ".*//g' -e 's/\/\*.*//g' -e 's/\/\/.*//g'` # Remove ` = "..."` + comments
if [[ ! -z $line ]] # Skip empty lines
then
res=`grep -Rn "$line" $PROJECT_DIRECTORY` # Find String in project
echo "$res" >> ./Localizable_results.txt
if [[ ! -z $res ]]
then
echo "$line" >> ./Localizable_results_found.txt
else
echo "$line" >> ./Localizable_results_not_found.txt
fi
echo "" >> ./Localizable_results.txt
fi
done < ./Localizable.strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment