#!/bin/sh

# Update language files specified in projectfile according to sources
./menugenerator -trans || exit 1

# process countable items localization
grep 'countString.*".*".*".*"' *.cc |perl -e '
 while (<>) {
  if (/"(.*)"[^"]+"(.*)"/) {
   print "QT_TRANSLATE_NOOP(\"QObject\",\"$1\",\"1\")\n";
   print "QT_TRANSLATE_NOOP(\"QObject\",\"$2\",\"2-4\")\n";
   print "QT_TRANSLATE_NOOP(\"QObject\",\"$2\",\"5+\")\n";
  }
 }
' >>.menu-trans.h

# process localizable strings in init.qs
grep "tr(" scripts/d*.qs *.qs | ./trans-qs.pl >>.menu-trans.h

lupdate pdfedit.pro
lrelease lang/*.ts

#generate template translation file
mkdir -p lang/template
lupdate -noobsolete pdfedit.lang
