/[d-i]/trunk/installer/doc/manual/scripts/mark_untranslated.awk
ViewVC logotype

Contents of /trunk/installer/doc/manual/scripts/mark_untranslated.awk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22119 - (show annotations) (download)
Mon Sep 27 18:43:52 2004 UTC (8 years, 8 months ago) by fjpop-guest
File size: 2929 byte(s)
- Moved all scripts to a ./scripts directory
- Moved some unused scripts to ./scripts/historic
- Created scripts to convert translations to .po files

1 BEGIN {
2 STRLINE = ""
3 TRANS_STATUS = 9
4
5 if (RANGE != "") {
6 # Check input range
7 if (match(RANGE, /^[0-9]+(:[0-9]+)?$/) == 1) {
8 TPOS = index(RANGE, ":")
9 if (TPOS > 0) {
10 RANGE_START = strtonum(substr(RANGE, 1, TPOS - 1))
11 RANGE_END = strtonum(substr(RANGE, TPOS + 1, length(RANGE)))
12 } else {
13 RANGE_START = strtonum(RANGE)
14 RANGE_END = strtonum(RANGE)
15 }
16 print "** Untranslating messages in range from " RANGE_START " to " RANGE_END "." >"/dev/stderr"
17 } else {
18 print "Range should be in format '<number>' or '<start>:<end>'." >"/dev/stderr"
19 exit 1
20 }
21 }
22 }
23
24 /^#: / {
25 line = $0
26 gsub(/^#: [^:]*:/, "", line)
27 TPOS = index(line, ", ")
28 STRLINE_PREV = STRLINE
29 if (TPOS == 0) {
30 STRLINE = line
31 } else {
32 STRLINE = substr(line, 1, TPOS - 1)
33 }
34 }
35
36 /^msgid / {
37 line = $0
38 gsub(/^msgid /, "", line)
39 MSGID = line
40 }
41
42 /^msgstr / {
43 line = $0
44 gsub(/^msgstr /, "", line)
45 MSGSTR = line
46
47 if (STRLINE != "") {
48 if (MSGID == MSGSTR) {
49 IS_TRANSLATED = 0
50 } else {
51 IS_TRANSLATED = 1
52 }
53
54 if (RANGE != "" && STRLINE >= RANGE_START && STRLINE <= RANGE_END) {
55 if (IS_TRANSLATED == 1) {
56 print "** String " STRLINE " looks translated, leaving unchanged!" >"/dev/stderr"
57 } else {
58 untranslate()
59 }
60 }
61
62 if (TRANS_STATUS == 9) {
63 TRANS_STATUS = IS_TRANSLATED
64 if (IS_TRANSLATED == 0) {
65 UNTRANS_START = STRLINE
66 }
67 } else {
68 if (TRANS_STATUS == 0 && IS_TRANSLATED == 1) {
69 # The previous strings were untranslated but this one is
70 if (STRLINE_PREV == UNTRANS_START) {
71 print "** String looks untranslated: " STRLINE_PREV >"/dev/stderr"
72 } else {
73 print "** Strings look untranslated: " UNTRANS_START " - " STRLINE_PREV >"/dev/stderr"
74 }
75 TRANS_STATUS = IS_TRANSLATED
76 }
77 if (TRANS_STATUS == 1 && IS_TRANSLATED == 0) {
78 TRANS_STATUS = IS_TRANSLATED
79 UNTRANS_START = STRLINE
80 }
81 }
82 }
83 }
84
85 {
86 # For all lines: if untranslating, write line to $filename.untrans
87 if (RANGE != "") {
88 print $0
89 }
90 }
91
92 END {
93 if (TRANS_STATUS == 0) {
94 print "** Strings look untranslated: " UNTRANS_START " - " STRLINE >"/dev/stderr"
95 }
96 }
97
98 function untranslate() {
99 print "** Untranslating string " STRLINE >"/dev/stderr"
100 print "msgstr \"\""
101 getline
102 # Skip other lines belonging to this msgstr
103 while (match($0, /^[[:space:]]*"/) > 0) {
104 getline
105 }
106 IS_TRANSLATED = 1
107 }

  ViewVC Help
Powered by ViewVC 1.1.5