#!/bin/sh
#
# Created 2005/02/08 by Simon Urbanek

# list of localizations we want to generate from English
LANGUAGES=`cat LANGUAGES`

# this is an exception - we actually merge into the english master, too
LANGUAGES="$LANGUAGES English"

# remove existing strings (if present)
rm -f Localizable.strings

# find all sources and run filterNLS on that list
find -X . -name \*.m 2> /dev/null | awk '{print substr($1,3)}' | xargs ./filterNLS

# now we have new Localized.strings in the current directory
if [ ! -e Localizable.strings ]; then
	echo "*** ERROR: Localizable.strings were NOT generated"
	exit 1
fi

# we need to merge that with the available languages
for LANG in $LANGUAGES; do
	if [ -e "$LANG.lproj" ]; then
		if [ -e "$LANG.lproj/Localizable.strings" ]; then
			echo "Updating $LANG ..."
			./mergeLS Localizable.strings "$LANG.lproj/Localizable.strings"
		else
			echo "-- $LANG has no localizable strings, creating them"
			cp Localizable.strings "$LANG.lproj/Localizable.strings"
		fi
	else
		echo "** $LANG is in the language list, but there is no lproj dorectory for it!"
	fi
done

rm Localizable.strings
echo "  Done."