Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localizing Xcode source files using genstrings?

I've gone trough my source files and updated all my strings using the NSLocalizedString() macro. Now because I have a lot of strings that come up across multiple source files , I decided to place a large amount of the strings in a header file called "LocalizedStringDefinitions.h" using the #define directive. So for example each line looks like this,

#define kLocalizedSTRINGNAME NSLocalizedString(@"STRINGNAME", @"Comment")

I just ran the genstrings command in terminal and the Localizable.strings file that was created contained only the localized strings that were directly placed in my code and none of the #defined ones. I have around 100 lines of #defined strings which I do not want to place back in my code especially because they appear across multiple files. How can I localize the strings?

like image 431
Christian Gossain Avatar asked Aug 02 '11 17:08

Christian Gossain


1 Answers

I just realized how simple this is. If you look a the Terminal command genstrings *.m the .m part is clearly specifying to look through the implementation files. The file with the #define's is a header file (.h) so by using the command genstrings *.h I was able to generate the .strings file, or I could just change the name of the file with the definitions to "LocalizableStringDefinitions.m"

like image 174
Christian Gossain Avatar answered Nov 08 '22 11:11

Christian Gossain