NSLocalizedStringWithDefaultValue(@"fantasy-group.group-rank.stats-label",nil,[NSBundle mainBundle],@"Group Rank",nil);
导出本地化时导致生成的.xliff文件中的以下块中的结果:
<trans-unit ID="fantasy-group.group-rank.stats-label"> <source>Group Rank</source> <note>No comment provIDed by engineer.</note> </trans-unit>
这从source开始按预期工作:
The main advantage to these macros is that they can be parsed by the
genstrings
tool and used to create your application’s strings files.
但是如果我尝试使用我自己的宏来避免指定表和bundle,并且可能在split up the string file中指定我自己的表:
#define WsllocalizedString(key,val,comment) \[[NSBundle mainBundle] localizedStringForKey:(key) value:(val) table:nil][WsllocalizedString(@"fantasy-group.group-rank.stats-label",nil);
当我尝试生成xliff文件时,XCode或关联的命令行工具无法获取它:
$xcodebuild -exportLocalizations -localizationPath WSL/Translations/ -project WSL.xcodeproj
如果我只是在做genstrings,我可以做以下source:
find . -name *.m | xargs genstrings -o en.lproj -s WsllocalizedString
但我想要xliffs.有没有一个参数我可以传递给xcodebuild来保持这个梦想活着?
解决方法 不确定Objective-C,但我通过重新定义NSLocalizedString函数为Swift做了这个:public func NSLocalizedString(key: String,tablename: String? = nil,bundle: NSBundle = NSBundle.mainBundle(),value: String = "",comment: String) -> String{ return yourBundleHere.localizedStringForKey(key,value: value,table: tablename)}
在我的情况下,我需要使用自定义NSBundle.
总结以上是内存溢出为你收集整理的使xcodebuild -exportLocalizations知道如何解析自定义NSLocalizedString宏全部内容,希望文章能够帮你解决使xcodebuild -exportLocalizations知道如何解析自定义NSLocalizedString宏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)