Created
November 3, 2014 06:55
-
-
Save Xenofex/8c85c192d277f9ebafa6 to your computer and use it in GitHub Desktop.
genstrings for Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# genstrings which searchs both Objective-C .m files and Swift files | |
# | |
# Set the 'PROJECT' variable | |
# I'm using a short function 'LS' to replace NSLocalizedString. This script searches them both. | |
# | |
if ! type -P ggrep >/dev/null; then | |
>&2 echo "Error: GNU grep 'ggrep' not found. Install by 'brew install homebrew/dupes/grep'" | |
exit 1 | |
fi | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
cd $DIR/.. | |
PROJECT=$DIR/../<YOUR PROJECT FOLDER HERE> | |
find $PROJECT -name '*.m' -o -name '*.swift' | xargs ggrep -hoP '(LS|NSLocalizedString)\(@?"\K.*?(?=")'| sort | uniq -u | gawk '{ print "\"" $0 "\" = \"" $0 "\";" }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment