Generate Localizable.strings file based on keys and comments

You may have a situation where you just start adding

NSLocalizedString(@"SOME_KEY", @"Comment as to its purpose")

calls throughout your code.

Now, the long-winded way of getting these into your Localizable.strings file is to copy-paste these keys over then provide a value for them. Or you can be a smart programmer (I’m not always, as it was a colleague who showed me this) and use a terminal command. We want to recursively search throughout our project’s folder and subfolders, find the NSLocalizedStrings calls, then have the script pick that out and put it into our .strings file.

The magic command is….

find . -name '*.m' -print0 | xargs -0 genstrings -a

the -a at the end will append it to your existing file(s).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s