iPhone-清理Localizable.strings [英] iphone - cleaning the Localizable.strings
问题描述
我有一个应用程序经历了一次大手术,很多东西都被修改了.
I have an app that suffered a major surgery and a lot of stuff was modified.
此应用曾经并且已经本地化为多种语言.
This app was and is localized to several languages.
我确定localizable.strings文件上的某些字符串将不再使用.其中至少有20%.有没有一种方法可以检查应用程序仍在使用哪些字符串,所以我可以摆脱所有语言文件中不必要的字符串?
I am sure that some of the strings on the localizable.strings file are no longer being used. At least 20% of them. Is there a way to check which strings are still being used by apps, so I can get rid of the unnecessary strings out of all language files?
谢谢.
推荐答案
您可以:
使用
genstrings -o临时目录* .m
然后从localizable.strings文件中删除等号的右侧,以使比较更加容易:
Then drop the right side of the equal sign from the localizable.strings file to make the comparison easier:
cat临时目录/本地化字符串|awk -F"\ ="'{print $ 1}'>Localizable_new.strings
对旧的" Localizable.strings执行相同的操作(假设您使用的是英文版本):
Do the same for the "old" Localizable.strings (assuming you have an English version):
cat en.lproj/Localizable.strings |awk -F"\ ="'{print $ 1}'>Localizable_old.strings
然后使用/Developer/Applications/Utilities/FileMerge
将 Localizable_old.strings 与 Localizable_new.strings 进行比较.
Then use /Developer/Applications/Utilities/FileMerge
to compare Localizable_old.strings with Localizable_new.strings.
根据多少 20%,您可以迅速"删除过时的行.
Depending on how much 20% are, you might get away with "quickly" deleting the obsolete lines.
我承认此过程可能很繁琐,还有很多改进的余地,例如,它不能正确处理注释中的等号,但这也许会有所帮助.
I admit this procedure might be tedious and has lots of room for improvement and for example it can't handle correctly equal signs in the comments, but maybe it helps.
我从来没有真正对以上感到满意.寻找一种易于维护的解决方案后,我最终停止使用NSLocalizedString并修改了代码以使用 NSLocalizedStringWithDefaultValue(<#key#>,<#tbl#>,<#bundle#>,<#val#> ;,<#comment#>)
I have never been truly happy with above. Looking for a solution easier to maintain I eventually stopped using NSLocalizedString and refractored the code to use NSLocalizedStringWithDefaultValue(<#key#>, <#tbl#>, <#bundle#>, <#val#>, <#comment#>)
现在,我对源代码中的本地化进行所有更改,然后运行genstrings.genstrings将覆盖Localizable.strings,但<#val#>"字段将在Localizable.strings中包含我想要的字符串.我不需要为原始语言编辑Localizable.strings.有关更多详细信息,请参见我的博客
Now I make all changes to the localization inside the source code, then run genstrings. genstrings will overwrite the Localizable.strings, but the '<#val#>' filed will contain the string I want inside Localizable.strings. I don't need to edit Localizable.strings for the original language. More details are in my Blog
这篇关于iPhone-清理Localizable.strings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!