On Aug 5, 2014, at 6:15 PM, Ken Thomases <[email protected]> wrote:

> On Aug 5, 2014, at 5:03 PM, Daryle Walker <[email protected]> wrote:
> 
>> If I change my localizable code from NSLocalizedString(@“My Key”, @“My 
>> Comment”) to NSLocalizedStringFromTable(@“My Key”, @“My Table”, @“My 
>> Comment”), can I use the class name as the table name via a macro? If I have 
>> a object type “MyClass" in “MyClass.m," do I have to use @“MyClass” 
>> directly, or can I hide it between a macro constant? A macro function? A 
>> full-blown Objective-C expression? Is the genstrings program smart enough to 
>> handle "NSStringFromClass([self class])"?
> 
> I don't believe it will do any of those things.  It doesn't preprocess your 
> code, let alone compile it or run it.  The expression [self class] is a 
> run-time expression.  It doesn't even reliably correspond to MyClass just 
> because it's in a method defined on MyClass.  That method may have been 
> invoked on an instance of a subclass, for example.
> 
> genstrings is a pretty "dumb" text processor.  Among other things, it will 
> find uses of NSLocalizedString and friends inside of comments, which is a 
> useful feature.
> 
> You have to use string literals.  (For some things, like the comment 
> parameter, it actually doesn't even matter if it's a C string literal or an 
> Objective-C string literal.)  I haven't tested but, if you use a macro, it 
> would either ignore that instance of NSLocalizedStringFromTable as one it 
> doesn't understand or, possibly, it would treat the macro _name_ as the table 
> name.

This has been my experience when using it, and it can be frustrating at times.

In terms of macros, I believe that it only detects them as Ken describes they 
appear inside a string; if not, according to at least one instance in my 
memory, it believes that it is a variable and ignores it.

It’s been awhile since I’ve been in this situation (I’ve since transitioned to 
using only strings) but if I am wrong I would appreciate it if someone who 
knows the true behavior corrects me.

> 
> Regards,
> Ken
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/sevenbitstech%40gmail.com
> 
> This email sent to [email protected]

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to