Browse Source

Fix full paths bug in applysed and perform some code cleanups and fixes.

master
Andrius Štikonas 11 years ago
parent
commit
fe6087bd52
3 changed files with 33 additions and 47 deletions
  1. +10
    -27
      applysed
  2. +20
    -17
      poupdate
  3. +3
    -3
      ths-variables

+ 10
- 27
applysed View File

@@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright 2007, Donatas Glodenis <dgvirtual@akl.lt>
# Copyright 2009, Andrius Štikonas <stikonas@gmail.com>
#
# #
# # This script is free software; you can redistribute it and/or modify
@@ -19,26 +20,15 @@
# ths-applysed.sh - apply a sed script to the whole project (the sed commands
# have to be supplied in an external file).

## example of the replacements file content (remove preceeding comment marks #
## and the ======== lines ):
# ==================
# s/bylai/failui/g
# s/bylą/failą/g
# s/byloje/faile/g
# ==================
source `dirname $0`/ths-variables

function usage() {
echo "Usage: `basename $0` <FULL-PATH-TO-file-with-replacement-list> <FULL-PATH-TO-base-directory>"
echo "WARNING: "
echo "SPECIFY FULL PATHS, OTHERWISE ALL YOUR FILES WILL BE DELETED!"
echo "DO A BACKUP BEFORE USING THIS SCRIPT!"
echo "Usage: `basename $0` <file-with-replacement-list> <base-directory>"
echo
echo "Example of the replacements file content"
echo "======== file begins ========"
echo "s/bylai/failui/g"
echo "s/bylą/failą/g"
echo "s/byloje/faile/g"
echo "======== file ends =========="
echo "Example of the replacements file content:"
echo "s/bylai/failui/"
echo "s/bylą/failą/"
echo "s/byloje/faile/"
exit 1
}

@@ -46,14 +36,7 @@ if [ $# -ne 2 ]; then
usage
fi

replacefile=$1
directory=$2

cd $directory

for po in `find . -name "*.po" | sort`
do
echo "Working on $po ..."
sed --file=$replacefile -i $po
echo "...done."
for po in `find $2 -name "*.po"`; do
echo -e $BLUE"$po"$ENDCOLOR
sed --file=$1 -i $po
done

+ 20
- 17
poupdate View File

@@ -76,19 +76,20 @@ upd_dir=$1
tra_tree=$2
tpl_tree=$3

total_files=`find $upd_dir -name "*.po" | wc -l`
newtrans=`cd $upd_dir; find . -name "*.po"`
total_files=`echo $newtrans | wc -w`
skipped_files=0
merged_files=0
changed_files=0


if [ "$option_verbose" = "Y" ]; then
echo "Checking if updated files are in the specified directory ..."
else
echo -ne "\r$merged_files/$total_files merged"
fi
newtrans=`cd $upd_dir; find . -name "*.po"`
if [ "$newtrans" == "" ]; then
echo " ... no updated files found in: $upd_dir"
echo -e $RED"\t\t... no updated files found in: $upd_dir"$ENDCOLOR
exit 1
else
if [ "$option_verbose" = "Y" ]; then
@@ -100,22 +101,25 @@ fi
## MAIN LOOP
for updfile in $newtrans
do

if [ `cd $tpl_tree; 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..."
if [ "$option_verbose" = "Y" ]; then
echo
echo "Strange, there is more than one template for `basename $updfile`,"
echo "cannot determine the right one,"
echo "SKIPPING..."
fi
continue
fi

if [ `cd $tra_tree; 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..."
if [ `cd $tpl_tree; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then
if [ "$option_verbose" = "Y" ]; 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..."
fi
continue
fi

@@ -173,8 +177,7 @@ if [ "`$DIFF $tra_tree/${trafile}.old $tra_tree/${trafile}.new`" ]; then
fi
fi

rm $tra_tree/${trafile}.new
rm $tra_tree/${trafile}.old
rm $tra_tree/${trafile}.old $tra_tree/${trafile}.new

merged_files=$(($merged_files+1))
if [ ! "$option_verbose" = "Y" ]; then


+ 3
- 3
ths-variables View File

@@ -25,7 +25,7 @@ MSGMERGE=`which msgmerge 2> /dev/null`
KDIFF3=`which kdiff3 2> /dev/null`

#Colors
RED="\033[1;31m"
GREEN="\033[1;32m"
BLUE="\033[1;34m"
RED="\033[0;31m"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
ENDCOLOR="\033[0m"

Loading…
Cancel
Save