Skip to content

Instantly share code, notes, and snippets.

@darrenclark
Last active June 20, 2016 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenclark/95b62e035b5349e244d94244fd4ab5aa to your computer and use it in GitHub Desktop.
Save darrenclark/95b62e035b5349e244d94244fd4ab5aa to your computer and use it in GitHub Desktop.
genstrings for your clipboard

(Swift only)

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

Usage:

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

  2. Pipe it through the pbgenstrings.sh script:

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

#!/bin/bash
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