Skip to content

Instantly share code, notes, and snippets.

Last active June 20, 2016 16:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
genstrings for your clipboard

(Swift only)

Easily add entries to Localizable.strings file by copy/pasting code with new NSLocalizedStrings


  1. Copy your code containing NSLocalizedString(_:comment:) function calls

  2. Pipe it through the script:

    $ pbpaste | ./ | pbcopy
  3. Paste contents of clipboard into your Localizable.strings file

egrep -o 'NSLocalizedString\(.+"\)' | sed 's/NSLocalizedString("//; s/", comment: "/|/; s/")$//' | awk 'BEGIN { FS="|" } { print "/* " $2 " */\n\"" $1 "\" = \"" $1 "\";\n" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment