l#!/bin/bash # # Copyright 2007, Donatas Glodenis # # # # # This script is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License 2 as published by # # the Free Software Foundation. # # # This script 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 script; if not, write to the Free Software # # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ths-poupdate.sh - takes a bunch of files from a single directory and transfers the translations therein to a translation file tree; may use the new files either as primary, or as secondary translations. ## BŪTINIEJI PATIKRINIMAI PRIEŠ CIKLĄ ## FUNKCIJOS function usage() { echo "Usage `basename $0` [options] " echo echo "Options:" echo " -P|--new-as-primary - use newly translated file translations " echo " as primary (default - use the new files" echo " as secondary translations)" exit 1 } ## PARAMETRAI while true do case $1 in -P|--new-as-primary) option_new_as_primary="Y" shift ;; -*|--*) usage ;; *) break ;; esac done # PATIKRINIMAS IR NAUDOJIMO PRANEŠIMAS if [ $# -ne 3 ]; then usage fi ## KELIŲ INTERPRETAVIMAS upddir=$1 tradir=$2 tpldir=$3 echo "Checking if updated files are in the specified directory ..." newtrans=`cd $upddir; find . -name "*.po"` if [ "$newtrans" == "" ]; then echo " ... no updated files found in: $upddir" exit 1 else echo " ... they are." fi echo ## PAGRINDINIS CIKLAS for updfile in $newtrans do if [ `cd $tpldir; find ${updfile}t 2> /dev/null | wc -l` -gt 1 ]; then echo echo "Strange, there is more than one template for `basename $updfile` , " echo "cannot determine the right one, " echo "SKIPPING... " # kopijuoti naują failą į vertimų medį continue # o gal ir ne taip daroma fi if [ `cd $tradir; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then echo echo "Strange, there is more than one version of translation `basename $updfile` , " echo "although there is only one translation template. There might be an extra" echo "unneeded file in your translation tree, check it out!" echo "Cannot determine the right file to translate, " echo "SKIPPING... " # kopijuoti naują failą į vertimų medį continue # o gal ir ne taip daroma fi if [ `cd $tpldir; find ${updfile}t 2> /dev/null | wc -l` -lt 1 ]; then echo echo "File `basename $updfile` does not belong to this translation project, " echo "SKIPPING... " find ${updfile}t -print continue # o gal ir ne taip daroma fi if [ `cd $tradir; find ${updfile} 2> /dev/null | wc -l` -lt 1 ]; then echo echo "File `basename $updfile` is completely newly translated, " echo "COPYING it to the appropriate place... " #finding the appropriate tplfile=`cd $tpldir; find ${updfile}t` secdir=`dirname $tplfile` cp $upddir/$updfile $tradir/$secdir/$updfile fi # atlikti msgmerge ir kitus veiksmus trafile=`cd $tradir; find $updfile` tplfile=`cd $tpldir; find ${updfile}t` mv $tradir/$trafile $tradir/${trafile}.old if [ "$option_new_as_primary" = "Y" ]; then echo echo "UPDATING $trafile using translations from $upddir/$updfile as PRIMARY translations" msgmerge -N -v --compendium=$tradir/${trafile}.old -o $tradir/${trafile}.new $upddir/$updfile $tpldir/$tplfile else echo echo "UPDATING $trafile using translations from $upddir/$updfile as SECONDARY translations" msgmerge -N -v --compendium=$upddir/$updfile -o $tradir/${trafile}.new $tradir/${trafile}.old $tpldir/$tplfile fi cat $tradir/${trafile}.new | sed '/X-Rosetta-Export-Date/d' > $tradir/$trafile rm $tradir/${trafile}.new rm $tradir/${trafile}.old done