Use genstrings with a folder-structured project for localization

爷,独闯天下 提交于 2019-12-24 10:28:46

问题


In an iOS Project with folders containing *.m files, similar to packages, one will have to run genstrings -o en.lproj *.m for each folder and match the relative en.lproj path. Is there a command that will do the drill down from the root folder?


回答1:


You can concatenate all of the *.m files into one file and then call the genstrings on that.

I.E:

find . -name "*.m" -exec cat {} >> all.txt \;



回答2:


In Greenwich we use find piped to xargs. You can see how that's done here, but it's basically:

find "path/to/directory" -name "*.m" -print0 |
  xargs -0 genstrings -s NSLocalizedString -o "path/to/output.strings"

I'd also recommend taking a look at Greenwich as it makes the whole process of localization much easier.




回答3:


if you have a simple folder struct you probably get away with a simple

genstrings -ao <destination> <root>/*/*.m

using one * for each level of subfolder.

Alternatively and if the folders have different nesting levels you are better off using:

  find <root>/* -iname "*.m"  -type f -print0 | xargs -0 genstrings -ao <destination>



回答4:


For me, this line just solved all problems. You even don't need to copy all m-Files to one document, before running the line in the shell. Just step into your project folder and run it, and all even the subfolders will be checked:

find . -name \*.m | xargs genstrings -o "directory/"

just create the directory before running it, otherwise you get an exception.



来源:https://stackoverflow.com/questions/9740518/use-genstrings-with-a-folder-structured-project-for-localization

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