-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lang
executable file
·108 lines (108 loc) · 1.86 KB
/
Lang
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
#!/bin/sh
#
# by Dirk Meyer (dinoex)
# Copyright (C) 2004-2018 Dirk Meyer
#
# By using this file, you agree to the terms and conditions set
# forth in the GNU General Public License. More information is
# available in the LICENSE file.
#
# If you received this file without documentation, it can be
# downloaded from http://iroffer.net/
#
# $Id$
#
lang="${1-de}"
lang="${lang%.txt}"
if test "${lang}" = "en"
then
for c in src/iroffer*.c src/dinoex*.c
do
if test -f "${c}.en"
then
echo \
mv -f "${c}.en" "${c}"
mv -f "${c}.en" "${c}"
fi
done
exit 0
fi
utf8="cat"
if test -n "${2}"
then
charset="${2}"
else
charset="utf-8"
case "${LANG}" in
*.ISO8859-*|*.ISO_8859-*)
# autodetect
charset="latin1"
;;
esac
fi
utf8="cat"
case "${charset}" in
utf-8)
;;
*)
case "${lang}" in
de|fr|it)
echo "latin1 conversion ..."
utf8="iconv -f utf-8 -t latin1"
;;
esac
;;
esac
echo -n "parsing ... "
sed -e 's| | |' en.txt > en.tmp
sed -e 's| | |' "${lang}.txt" > "${lang}.tmp"
join -t ' ' en.tmp "${lang}.tmp" |
sed -e 's|^[0-9]*|s|' -e 's|"$|" g|' |
awk -F ' ' '
{
if ( $2 == $3 )
next
print
}
' |
${utf8} |
sed -e 's|\\|\\\\|g' -e 's|\*|\\*|g' -e 's|\+|\\+|g' -e 's|\.|\\.|g' -e 's|\[|\\[|g' -e 's|\]|\\]|g' -e 's|\&|\\&|g' > "${lang}.sed"
rm -f en.tmp "${lang}.tmp"
echo "done"
if test ! -d "src.${lang}"
then
mkdir "src.${lang}"
fi
for c in src/iroffer*.c src/dinoex*.c
do
l="src.${lang}/${c#src/}"
sed -f "${lang}.sed" "${c}" > "${l}.new"
if test -f "${l}"
then
if diff -q "${l}" "${l}.new"
then
rm -f "${l}.new"
continue
fi
fi
echo \
mv -f "${l}.new" "${l}"
mv -f "${l}.new" "${l}"
done
for c in src/*.h src/[bcpsu]*.c
do
l="src.${lang}/${c#src/}"
cp -p "${c}" "${l}.new"
if test -f "${l}"
then
if diff -q "${l}" "${l}.new"
then
rm -f "${l}.new"
continue
fi
fi
echo \
mv -f "${l}.new" "${l}"
mv -f "${l}.new" "${l}"
done
# eof