How To Make NSLocalizedString Fun To Use

To localize apps (which means: to make them work in other languages) you need to avoid using plain @”strings” and instead use the one of the tedious functions NSLocalizedString, NSLocalizedStringFromTable, or NSLocalizedStringFromTableInBundle, that take two to four arguments. Horror.

I mean, any sane programmer will get a headache from replacing a simple @"Great!" with this:

So I took a leaf from WordPress, and shortened the calls:

Now localization is easy and fun: I simply type __(@"Great!") and the localization code is taken care of by the C pre-processor. Mission accomplished.

Leave a Reply