File: poedit

package info (click to toggle)
potool 0.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 136 kB
  • ctags: 60
  • sloc: ansic: 327; yacc: 160; sh: 95; makefile: 74
file content (71 lines) | stat: -rwxr-xr-x 1,179 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
#!/bin/bash

#
# Set up tmp file
#

POTMP=${TMPDIR:-${TMP:-/tmp}}
if [ ! -d $POTMP -o ! -w $POTMP ]
then
	echo $POTMP does not exist or is not writable
	exit 1
fi
TMPFILE=`mktemp $POTMP/poedit.XXXXXX` || exit 1

#
# Check what msgs to include
#

if [ "$1" = "-a" ]
then
	INCLUDE_ALL_MSGS=yes
	POFILE="$2"
else
	INCLUDE_ALL_MSGS=no
	POFILE="$1"
fi

#
# Some sanity checks
#

if [ -z "$POFILE" -o ! -w "$POFILE" ]; then
	echo 'edit what?!' 1>&2
	exit 1
fi

EDITCMD=sensible-editor

#
# Filter the file
#

if [ "$INCLUDE_ALL_MSGS" = "yes" ]
then
	potool "$POFILE" -ft > "$TMPFILE"
	echo >> "$TMPFILE"
else
	echo -n '' > "$TMPFILE"
fi
potool "$POFILE" -fnt >> "$TMPFILE"

#
# Run editor and update the file on success
#

$EDITCMD "$TMPFILE"
if [ $? -eq 0 ]; then
	mv "$POFILE" "$POFILE~"
	potool "$POFILE~" "$TMPFILE" > "$POFILE" 
	if [ $? -eq 0 ]; then
		printf "Before: %s/%s\n" `potool -ft -s "$POFILE~"` `potool -s "$POFILE~"` 
		printf "After:  %s/%s\n" `potool -ft -s "$POFILE"` `potool -s "$POFILE"` 
		rm -f "$POFILE~" "$TMPFILE"
	else
		mv -f "$POFILE~" "$POFILE"
		echo "Temp. file: " $TMPFILE
	fi
else
	echo $EDITCMD exited abnormally, not updating the po file
	exit 1
fi