列出本地化文件
科尼奇瓦的各位, 我正在绞尽脑汁地研究一个非标准程序来读取我的项目中的一堆本地化 xml。
我的目的是递归地读取所有这些文件,以便为 coredata sqlite 数据库提供数据以创建同一数据库的各种基于 lang 的版本。
首先,我尝试了一种老式技术,例如:
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:nil];
NSArray *onlyXMLs = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.xml'"]];
for (NSString *tString in onlyXMLs) {
/* stuff */
}
一点运气都没有,因为它会弹出我的项目中的所有非本地化 xml,仅此而已。
所以我想知道是否有办法让那些该死的未本地化的 xml 出来。
提前致谢。
如果您有疑问或疑问,请给我留言。
-k-
Konichiwa folks,
I'm banging my head over a non-standard procedure to read a bunch of localized xml located in my project.
My purpose is to read recursively all these files in order to feed a coredata sqlite db to create various lang-based versions of the same DB.
In the first place, I've tried an old school technique, like:
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:nil];
NSArray *onlyXMLs = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.xml'"]];
for (NSString *tString in onlyXMLs) {
/* stuff */
}
with no luck at all, because it pops out all the non-localized xmls in my project and nothing more.
so I was wondering if there would be a way to get those damn't localized xmls out there.
thanks in advance.
If u got doubts or questions don't be a stranger, drop me a line.
-k-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,解决了!
对于那些正在寻求问题答案的人,这里是解决方案:
记住携带所需语言的参数
必须始终与项目中包含所需文件的 .plist 目录相同。
因此,如果您有一个包含您需要的内容的 English.plist,那么它也必须是要传递的名称字符串(如上面的示例所示),否则,如果您正在处理 en.plist,@" en" 应该是字符串。
就是这样,就是这样。
ok, solved it!
for the ones who are seeking for an answer to the problem, here's the solution:
remember that the parameter that carries the desired language
must always be the same of the .plist directory containing the desired files in your project.
so if you've got a English.plist with the stuff you need in it, that must also be the name string to pass (like shown in the above example), otherwise if you're dealing with a en.plist, @"en" shall be the string.
that's it, that's all.