#!/bin/bash

COPYRIGHT_HOLDER="antiX Linux"
PACKAGE_NAME="antiX Development"
BUGS_TO="translation@antixlinux.org"

out_dir="Private/pot/"
cat_file="$out_dir/cli-shell-utils.pot"
str_file="$out_dir/strings"

files="
../live-usb-maker/live-usb-maker
../live-usb-maker/dd-live-usb
../live-kernel-updater/live-kernel-updater
../cli-shell-utils/cli-shell-utils.bash"

xgt_opts="--no-location --add-comments --no-wrap --language=Shell"

ofile_list=

mkdir -p "$out_dir"

all_file="${out_dir%/}/all"

cat $files > "$all_file"

ofile=$cat_file

xgettext $xgt_opts \
    --copyright-holder="$COPYRIGHT_HOLDER" \
    --package-name="$PACKAGE_NAME" \
    --msgid-bugs-address="$BUGS_TO" \
    -o "$ofile" "$all_file" 2>/dev/null

sed -i "s/charset=CHARSET/charset=UTF-8/" $ofile

egrep "^(msgid|#\.)" $cat_file | sed "s/^msgid //" | sed -r 's/^"|"$//g' > $str_file

lines=$(grep ^msgid $cat_file | wc -l)
words=$(grep ^msgid $cat_file | wc -w)
words=$((words - lines))
lines=$((lines - 1))

echo
printf "%4s strings to translate\n" $lines
printf "%4s words in the strings\n" $words
