开发者

Batch localize using IBTools?

Is there a way to run IBTools on a bunch of NIB files with a single command? I'm trying to extract strings from NIBs. Am I supposed to run ibtools once for each NIB?

I find it t开发者_如何转开发edious to run IBTools so many times. (I have only 9 NIB files. It could be worse...)


I don't think ibtool can take multiple files as argument. The only way I see would be to write a bash script to perform this task.

#!/bin/bash

find . -name "*.xib" | while read FILENAME;
do
  ibtool --export-strings-file $FILENAME.strings $FILENAME
done


Here is a much more full featured script I made to use for the same operation:

#!/bin/bash
# Argument = -o output_dir -i input_dir

usage()
{
cat << EOF
usage: $0 [options]

This script generates strings files from all xibs in a given directory.

OPTIONS:
   -h      Show this message
   -i      Input directory where XIBs are located [./]
   -o      Output directory where .strings files will be generated
EOF
}

INPUT_DIRECTORY="."
OUTPUT_DIRECTORY="."

while getopts “hi:o:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         i)
             INPUT_DIRECTORY=$OPTARG
             ;;
         o)
             OUTPUT_DIRECTORY=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

if [[ -z $INPUT_DIRECTORY ]] || [[ -z $OUTPUT_DIRECTORY ]]
then
     usage
     exit 1
fi

# do the generation

find $INPUT_DIRECTORY -name "*.xib" | while read FILENAME;
do
  XIBNAME=$(basename "$FILENAME")
  XIBNAME="${XIBNAME%.*}"
  ibtool --generate-strings-file $OUTPUT_DIRECTORY/$XIBNAME.strings $FILENAME
done
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜