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

匆匆过客 提交于 2019-11-29 21:06:26

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!