#!/bin/sh
# PDFedit - free program for PDF document manipulation.
# Copyright (C) 2006-2009  PDFedit team: Michal Hocko,
#                                        Jozef Misutka,
#                                        Martin Petricek
#                   Former team members: Miroslav Jahoda
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (in doc/LICENSE.GPL); if not, write to the 
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA  02111-1307  USA
#
# Project is hosted on http://sourceforge.net/projects/pdfedit

# (re)build menugenerator
make -f Makefile.gui menugenerator || exit 1

# 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
