Christian Gossain
Christian Gossain

Reputation: 5972

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?

Upvotes: 6

Views: 3214

Answers (1)

Christian Gossain
Christian Gossain

Reputation: 5972

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"

Upvotes: 6

Related Questions