#!/bin/bash

rm -rf data
mkdir data
(cd ../data && make used_levels)
for ldfile in $(cat ../data/used_levels) ; do
  ./cual2fakec ../data/$ldfile > data/$ldfile ;
done

rm -rf src
mkdir src
cp ../src/*.cpp ../src/*.cc ../src/*.h src

# Charset handling might appear inefficient. It is.
# When trying to improve it, please handle the case, that all translatable
# strings are in ASCII, and the case that some (like level authors' names)
# are in ISO-8859-1 but not in ASCII.
# Unfortunately, xgettext behaves quite differently in both cases.

xgettext \
    --from-code=ISO-8859-1 \
    --language=C++ \
    --keyword=_ \
    --keyword=N_ \
    --add-comments=TRANSLATORS \
    --msgid-bugs-address=cuyo-devel@nongnu.org \
    -o - \
    src/* data/* \
  | sed \
    -e "1 s/SOME DESCRIPTIVE TITLE/Message catalog for the game Cuyo/" \
    -e "2 s/Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER/This is a partly generated file. The copyright of the original messages is identical to the one of the source files they are generated from. The copyright of the translations is by the translators./" \
    -e "3,9 s/PACKAGE/Cuyo/" \
    -e "16 s/CHARSET/ASCII/" \
  | msgconv -t ISO-8859-1 \
  > cuyo.pot

