7

The macros iOS has for creating localized strings are pretty awesome when used with genstrings. However, I'd like to create my own #define on top of one of the macros like so:

#define MyLocalizedStringWithDefaultValue(key, tbl, val, comment) \
NSLocalizedStringWithDefaultValue(key, tbl, [NSBundle mainBundle], val, comment)
#endif

Essentially, I always want to be going against the main bundle, so I don't feel the need to type it out every time. This works great in code, but genstrings doesn't pick up my macro. Is there anything I can do to make it pick up my custom macro? I saw on the man page that there's a routine parameter that looks like what I'm trying to do, but I was unable to get it to work.

1 Answer 1

4

Type genstrings to see the help text. Notice the -s substring option. You want something like:

genstrings -s MyLocalizedString -o someDir *.m
8
  • Yes, I tried that. The command I'm running is genstrings *.m -s MyLocalizedStringWithDefaultValue but it's not picking up the macro
    – Mike
    Commented Dec 14, 2012 at 16:29
  • 1
    That's the wrong value. Look at what I showed compared to what you are using for the -s option.
    – rmaddy
    Commented Dec 14, 2012 at 16:34
  • I'm still confused. Are you saying I should be using MyLocalizedString instead of MyLocalizedStringWithDefaultValue? That wouldn't make sense, as my macro is called MyLocalizedStringWithDefaultValue.
    – Mike
    Commented Dec 14, 2012 at 19:08
  • 2
    Yes, that is what I am saying. Run the genstrings command with no arguments and look at what it says for the -s argument. It expects the prefix to use instead of NSLocalizedString.
    – rmaddy
    Commented Dec 14, 2012 at 21:18
  • 1
    I'm looking to remove the bundle and eventually table parameters altogether. The rest of my team is going to start hammering on this in a month or two, and the more I can prevent them from going away from the standard the better.
    – Mike
    Commented Dec 17, 2012 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.