我想将Localizable.strings文件转换为JSON:
"Key" = "Localized Str";
至
"Key" : "Localized Str",
有没有现成的解决方案?还是更好地编写自己的脚本?
最佳答案
NSString *path = [[NSBundle mainBundle] pathForResource:@"Localizable"
ofType:@"strings"
inDirectory:nil
forLocalization:@"en"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:NSJSONWritingPrettyPrinted
error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
关于ios - 将Localizable.strings转换为json,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20995364/