[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

ddtp [SCRIPT]: merging translations with english package description files

Hi all,

I wrote a small script which simplifies the usage of translated package 
descriptions. Please see the comments in it for details.

Feel free to use and distribute it.

PS: Please CC me, as I'm not subscribed to this list.


# Copyright 2003 Jens Seidel <tux-master@web.de>
# License: GPL v2 or higher (at your opinion)

# This script inserts (in most cases translated) package descriptions 
from the
# first file into the second and writes the result to stdout.

# This is more useful than
#   http://ddtp.debian.org/aptable de/unstable main
# at the beginning of /etc/apt/sources.list, because APT doesn't try to 
# files (which may be more up to date) from ddtp.debian.org/ but uses the 
# ones.

# Package files can be found in /var/lib/apt/lists/.

# Application: Assume translated package files can be found in
# ~/dists/de/woody/main/binary-i386/Packages:
# cd /var/lib/apt/lists
# for i in $(ls *Packages); do
#  mv $i /tmp
#  change-pkg-description ~/dists/de/woody/main/binary-i386/Packages 
/tmp/$i > $i
# done 


if [ $# -ne 2 ]; then
  echo "$0 usage: $(basename $0) i18nfile packagefile"
  echo "This script replaces the package descriptions in packagefile with 
  echo "corresponding strings from i18nfile (they must exist) and writes 
  echo "output to stdout."
  echo "This is useful to translate package descriptions even if the 
versions of both"
  echo "files does not match."

if [ $1 = $2 ]; then
  echo "Argumnts must be different."
  exit 1

gawk -F"\n" '
  # start of text
  /^Description: / { 
    if (FILENAME!="'$f'") print description[package]
  /^Package: / { copyText=0 }
  { if (copyText && FILENAME=="'$f'") text[++lines]=$0 } 
  { if (!copyText && FILENAME!="'$f'") print $0 }
  /^Package: / {
    if (FILENAME=="'$f'" && lines>0)
      for (i=1;i<=lines;i++)
        description[package]=description[package] text[i] "\n"
  END {
    if (FILENAME=="'$f'")
      for (i=1;i<=lines-1;i++)
        description[package]=description[package] text[i] "\n"
' $1 $2

Reply to: