Localizing Xcode source files using genstrings?

I went through the source files and updated all my lines using the NSLocalizedString () macro. Now, since I have many lines that appear in several source files, I decided to place a large number of lines in the 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 the terminal, and the Localizable.strings file that was created contained only the localized strings that were directly placed in my code, and none of #defined. I have about 100 lines of #defined lines that I don’t want to return to my code, especially because they appear in multiple files. How can I localize strings?

+6
source share
1 answer

I just realized how simple it is. If you look at the genstrings *.m terminal genstrings *.m , the .m part explicitly indicated that you need to view the implementation files. The C # define file is a header (.h) file, so using the genstrings *.h command I was able to generate a .strings file, or I could just change the name of the definition file to "LocalizableStringDefinitions.m" "

+6
source

Source: https://habr.com/ru/post/894129/


All Articles