public
Last active

extract strings from m's and xib's

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5
#!/bin/sh
 
find . -name *.xib | xargs ruby -ne '$_.match(/<string key="(.*)">(.*)<\/string>/){|m|puts "\"#{m[2]}\" = \"#{m[2]}\";" if m[1] =~ /IB.*Title/}'
find . -name *.m | xargs ruby -ne '$_.scan(/NSLocalizedString\s*\(\s*@"([^"]*)"\s*,[^)]*\)/){|m|puts "\"#{m[0]}\" = \"#{m[0]}\";"}'
find . -name *.m | xargs ruby -ne '$_.scan(/__\(\s*@"([^"]*)"\s*\)/){|m|puts "\"#{m[0]}\" = \"#{m[0]}\";"}'
find . -name *.m | xargs ruby -ne '$_.scan(/__\(\s*@"([^"]*)"\s*\)/){|m|puts "\"#{m[0]}\" = \"#{m[0]}\""}'
find . -name *.m | xargs ruby -ne '$_.scan(/NSLocalizedString\s*\(\s*@"([^"]*)"\s*,[^)]*\)/){|m|puts "\"#{m[0]}\" = \"#{m[0]}\""}'

.scan is used instead of .match so it matches multiple times in a single line.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.