iphone - reading from Localizable.strings file as a key-value in a dictionary

后端 未结 4 1219
别跟我提以往
别跟我提以往 2020-12-08 16:56

I want to read the text from the localizable.strings file. I am collecting the strings for translation from several directories and file in one .strings file. But then I hav

4条回答
  •  猫巷女王i
    2020-12-08 17:23

      NSString *path = [[NSBundle mainBundle] pathForResource:@"Localizable"
                                                       ofType:@"strings"                                                       
                                                  inDirectory:nil
                                              forLocalization:@"ja"];
    
      // compiled .strings file becomes a "binary property list"
      NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
    
      NSString *jaTranslation = [dict objectForKey:@"hello"];
    

提交回复
热议问题