Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 312
sorin Avatar asked Apr 21 '11 12:04

sorin


1 Answers

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 '{}'
like image 128
Lukasz Avatar answered Sep 17 '22 13:09

Lukasz