String Constant as a Localized String

前端 未结 6 2071
深忆病人
深忆病人 2021-02-13 18:14

I would like to localize my constants. Constants are defined and declared the usual way:

extern NSString * const kStringName;

NSString * const kStringName = @\"         


        
6条回答
  •  自闭症患者
    2021-02-13 18:30

    I've created a PHP script that takes a correctly formatted Localizable.strings file as input and produced a Localizable.h file as output containing appropriate #define-commands for each String-Key. You can modify it as you see fit.

    The script expects all string keys to be formatted with sub-words split by uppercase letters, so a line should look like this in your Localizable.strings file:

    "SectionSomeString" = "This is my string.";
    

    which would then be converted to

    #define SECTION_SOME_STRING NSLocalizedString(@"SectionSomeString", nil)
    

    The PHP script looks as follows:

    
    

提交回复
热议问题