Why doesn't genstrings convert NSLocalizedStringFromTable entries to table.strings?

3.3k Views Asked by At

In my source code I have some lines like NSLocalizedStringFromTable(@"Info", @"en", @"Title of this view"). When I subsequently call genstrings -o en.lproj ./Classes/*.m I would not get the expected file en.strings but Localized.strings, although I've read in the genstrings-manpage that it would generate a table.strings file from NSLocalizedStringFromTable(a, table, c) function. Am I wrong? How would I create a table.strings file then?

1

There are 1 best solutions below

0
On

Juan,

Make sure you're NOT using a #define or constant for the table name. Remember, genstrings doesn't look at the compiled code, it just parses the source file. Also, all of the NSLocalizedStrings methods are actually just macros defined in NSBundle.h:

#define NSLocalizedStringFromTable(key, tbl, comment) \
        [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:(tbl)]

Make sure you aren't doing something like:

#define ENSTRINGS @"en"
...
NSString *info = NSLocalizedStringFromTable( @"Info", ENSTRINGS, @"Title of this view" );

Instead, you must specify the table name:

NSString *info = NSLocalizedStringFromTable( @"Info", @"en", @"Title of this view" );