Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 tedious to run IBTools so many times. (I have only 9 NIB files. It could be worse...)

like image 377
Moshe Avatar asked Apr 29 '11 04:04

Moshe


2 Answers

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
like image 99
Hugo Briand Avatar answered Oct 25 '22 00:10

Hugo Briand


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
like image 20
Ben Lachman Avatar answered Oct 24 '22 23:10

Ben Lachman