1
我想轉換Localizable.strings文件,以JSON:轉換Localizable.strings到JSON
"Key" = "Localized Str";
要
"Key" : "Localized Str",
有沒有現成的解決方案?或者更好地寫自己的腳本?
我想轉換Localizable.strings文件,以JSON:轉換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];