开发者

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

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 th开发者_StackOverflow中文版at 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?


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" );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜