File: createdesktop

package info (click to toggle)
skim 1.4.4-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,876 kB
  • ctags: 1,247
  • sloc: cpp: 9,421; python: 1,608; sh: 260; makefile: 68
file content (131 lines) | stat: -rwxr-xr-x 2,514 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#! /bin/bash

test -z "$VERBOSE" || echo "creating desktop file"

if test -n "$2"; then
  outputfile=$2
else
  outputfile=desktop.pot
fi
filelist=$1
cachefile=`tempfile`

rm -f $outputfile
rm -f $cachefile
touch $cachefile

if test ! -r $filelist; then
  echo "ERROR: no file list"
  exit
fi

date=`date +"%Y-%m-%d %H:%M%z"`
echo "#, fuzzy" >> $outputfile
echo "msgid \"\"" >> $outputfile
echo "msgstr \"\"" >> $outputfile
echo "\"Project-Id-Version: desktop files\n\"" >> $outputfile
echo "\"POT-Creation-Date: $date\n\"" >> $outputfile
echo "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n\"" >> $outputfile
echo "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n\"" >> $outputfile
echo "\"Language-Team: LANGUAGE <LL@li.org>\n\"" >> $outputfile
echo "\"MIME-Version: 1.0\n\"" >> $outputfile
echo "\"Content-Type: text/plain; charset=UTF-8\n\"" >> $outputfile
echo "\"Content-Transfer-Encoding: ENCODING\n\"" >> $outputfile
echo "" >> $outputfile

function grepTag() {
   testfile=`tempfile`
   rm -f $testfile
   grep "^$tag=" $file | sed -e "s#^$tag=\(.*\)#\1#" > $testfile
   if test -f $testfile; then
     lines=`cat $testfile | wc -l`
   else
     lines=0;
   fi
   line=0
   orig=
   esc=
   has=no

   until test ! "$line" -lt "$lines"; do

   line=`expr $line + 1`

   orig=`head -n $line $testfile | tail -n 1`
   esc=`echo $orig | sed -e 's#\"#\\\\"#g'`
   has=yes

   if test -n "$warn" && test -z "$orig"; then
     echo "desktop file without $tag entry: $filename"
     has=no
   fi

   if test "$has" = "yes"; then
     if grep -q "^$tag=$orig$" $cachefile; then
       test
     else
       echo "$tag=$orig" >> $cachefile

       echo "#: $filename:$number" >> $outputfile
       echo "msgid \"$tag=$esc\""  | sed -e 's#\\n#\\\\n#g' >> $outputfile
       echo "msgstr \"\"" >> $outputfile
       echo "" >> $outputfile

     fi
   fi

   done

   rm -f $testfile
}

list=`cat $filelist`

for file in $list; do
   echo "parsing $file"

   filename=`echo $file | sed -e "s#^\./##"`

   if test ! -f $filename; then
     echo "can't find $filename"
   fi

   warn=
   tag=Name
   number=1
   grepTag

   orig_name="$orig"

   warn=
   tag=Comment
   number=2
   grepTag

#   if test "$orig" = "$orig_name"; then
#     echo "comment is the same as name: $filename" >&2
#   fi

   tag=Language
   number=3
   grepTag

   tag=Keywords
   number=4
   grepTag

   tag=About
   number=5
   grepTag
   
   tag=Description
   number=6
   grepTag

   tag=GenericName
   number=7
   grepTag

done

rm -f $cachefile