gpt4 book ai didi

ios - 将Localizable.strings转换为json

转载 作者:行者123 更新时间:2023-12-01 17:54:20 25 4
gpt4 key购买 nike

我想将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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com