Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
Created April 5, 2012 11:23
Show Gist options
  • Save simonwhitaker/2310061 to your computer and use it in GitHub Desktop.
Save simonwhitaker/2310061 to your computer and use it in GitHub Desktop.
Generate a basic .strings file for each .plist of an iOS Settings.bundle
#!/bin/bash
# NB: next line assumes that this script is in the root
# of your Settings.bundle directory. Feel free to adapt
# accordingly.
base_dir=$(dirname $0)
for plist in *.plist; do
# Generate the name of the matching .strings file
outfile=en.lproj/${plist%.*}.strings
echo "Generating $outfile from $plist"
# Step 1: convert plist to formatted JSON for easy parsing
# Step 2: use Perl (old skool!) to pick out the values for the Title keys
# Step 3: convert output to UTF-16
plutil -convert json -r -o - $base_dir/Root.plist \
| perl -ne '/"Title" : (.+)/ && print "$1 = $1;\n"' \
| iconv -t UTF-16 > $base_dir/$outfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment