PDA

View Full Version : Better version of genstrings




Eraserhead
Nov 8, 2009, 06:35 AM
Hey guys

Is there a better version of genstrings that allows you to use the first value of NSLocalizedString only as a key and the second as the value?

Otherwise I think it'll be easier to write a new tool than to change what I've already written in my project :p.

Thanks



chown33
Nov 8, 2009, 03:20 PM
Not a "better genstrings", but maybe a better production pathway:
http://wilshipley.com/blog/2009/10/pimp-my-code-part-17-lost-in.html

Eraserhead
Dec 1, 2009, 12:42 PM
So I put my money where my mouth is and coded this solution - and you can download my hard work from Sourceforge at http://www.sourceforge.net/projects/cocoalocalizer/.


Rather than go back and redo my coding so that it would work I created a new program called CocoaLocalizer to do this hard work for me. This program creates better comments than genstrings as it allows you to import comments from an external file with the same keys, and it also displays the ‘default value’ in the comment so you can see what you’re translating from. Additionally it allows you to ‘merge’ another .strings file (though it misses the comments in that at the moment) into the one it generates. Also the application checks both the keys and values to make sure they don’t clash with existing values and displays a ‘nice’ error for this.

It also works with NSLocalizedString done in the default way as well (i.e. NSLocalizedString(keyValue, comment) and with that it just uses the extra comment from the comment.strings file as another comment.

This program has a Cocoa interface and isn’t a command line application and it requires Mac OS X 10.6 Snow Leopard.

(source (http://matthewhutton.com/software/2009/12/cocoalocalizer/))

kainjow
Dec 1, 2009, 12:55 PM
You should make it a command-line tool, because that is often how genstrings is used and that's how we use it in a large project, where it takes several seconds (10-15) to process all our code (we only run it on Release atm). I don't think genstrings uses any sort of multi-threading, so that could be something to consider for yours as well (easy with NSOperation).

BTW the download from SF contained a folder with a .app extension, but it was only a normal folder, so it wouldn't open properly.

Eraserhead
Dec 1, 2009, 02:15 PM
BTW the download from SF contained a folder with a .app extension, but it was only a normal folder, so it wouldn't open properly.

Fixed.

You should make it a command-line tool, because that is often how genstrings is used and that's how we use it in a large project, where it takes several seconds (10-15) to process all our code (we only run it on Release atm).

On D&D Manager genstrings takes 7.06 seconds (according to the Unix command time), whereas my code only takes 0.08 seconds (according to the creation of a date at the start/end of my method) which is a huge improvement - I haven't used any threading so far but I'm not sure its needed.

You should make it a command-line tool, because that is often how genstrings is used and that's how we use it in a large project,

Doing it as a command line application sounds like a good idea - I'll take a look at doing that.

ohrmazd
Dec 23, 2011, 06:09 AM
thank you for the cocoalizer,
i found a good link for using genstrings recursively, if anyone's interested:
find . -name '*.m' | xargs genstrings

Reference http://www.gargoylesoft.com/blog/2011/02/localizable-strings