开发者

How can I extract all localizable strings from all XIB files into one file?

I am looking for a way of extracting all localizable strings from .xib files and have all of them saved in a single file.

Probably this involves ibtool but I was not able to determine a way of merging all these in only one translation dictionary (could be .strings, .plist开发者_开发技巧 or something else).


Open terminal and cd to the root directory of the project (or directory where you store all XIB files) and type in this command:

find . -name \*.xib | xargs -t -I '{}' ibtool --generate-strings-file '{}'.txt '{}'

The magic is the find and xargs commands working together. -I option generates placeholder. -t is just for verbose output (you see what commands has been generated and executed). It generates txts files with the same name as xib files in the same directory. This command can be improved to concatenate output into one file but still is a good starting point.

Joining them together:

You can concatenate those freshly created files into one using similar terminal command:

find . -name \*.xib.txt | xargs -t -I '{}' cat '{}' > ./xib-strings-concatenated.txt

This command will put all strings into one file xib-strings-concatenated.txt in root directory.

You can delete generated partial files (if you want) using find and xargs again:

find . -name \*.xib.txt | xargs -t -I '{}' rm -f '{}'


this is a lot easier now.

in xcode, select your project (not a target)

then use menu/editor/export for localisation

xcode will output an xliff file with all localisable strings from your entire project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜