Skip to content

Instantly share code, notes, and snippets.

@orlandoaleman
Created March 3, 2013 14:36
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 orlandoaleman/5076340 to your computer and use it in GitHub Desktop.
Save orlandoaleman/5076340 to your computer and use it in GitHub Desktop.
Extracts title and footer texts from Settings.bundle plists to your *.strings localized files. Usage: plist2strings.sh Settings.bundle/Root.plist Settings.bundle/es.lproj/Root.strings
#!/bin/sh
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 2 ] || die "2 arguments required, $# provided"
[ -e $1 ] || die "File \"$1\" does not exist"
sed -n '
# look for a "#" at the end of the line
/<key>Title<\/key>$/ {
# Found one - now read in the next line
N
# delete the "#" and the new line character,
s/.*<\(string\)>\(.*\)<\/\1>/"\2" = "\2";/gp
}' $1 >> $2
sed -n '
# look for a "#" at the end of the line
/<key>FooterText<\/key>$/ {
# Found one - now read in the next line
N
# delete the "#" and the new line character,
s/.*<\(string\)>\(.*\)<\/\1>/"\2" = "\2";/gp
}' $1 >> $2
cat $2 | sort | uniq > tmpfile
rm $2
mv tmpfile $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment