0

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?

jscs
  • 63,694
  • 13
  • 151
  • 195
Yogev Shelly
  • 1,373
  • 2
  • 13
  • 24

4 Answers4

2

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 \;
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • i have created file with your instructions but unable to use genstrings command on that. can you please elaborate the line to deal with txt file ? – IDev May 18 '15 at 08:11
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.

wbyoung
  • 22,383
  • 2
  • 34
  • 40
1

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.

Alex Cio
  • 6,014
  • 5
  • 44
  • 74
1

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>
Olaf
  • 3,042
  • 1
  • 16
  • 26