|
Revision 1101, 0.8 KB
(checked in by moo, 10 months ago)
|
|
devel: use gettext to scan translate string
|
-
Property svn:executable set to
*
|
| Rev | Line | |
|---|
| [1101] | 1 | #!/usr/bin/awk -f |
|---|
| 2 | BEGIN { |
|---|
| 3 | print "<?php"; |
|---|
| 4 | print ""; |
|---|
| 5 | print "$strings += array("; |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | function flushOut() { |
|---|
| 9 | if (section) { |
|---|
| 10 | if (section == "msgstr") { |
|---|
| 11 | if (msgid == "") { |
|---|
| 12 | } |
|---|
| 13 | else { |
|---|
| 14 | print "\t\""msgid"\""; |
|---|
| 15 | print "\t=> \""msgstr"\","; |
|---|
| 16 | } |
|---|
| 17 | } |
|---|
| 18 | else { |
|---|
| 19 | print "unexpected section " section; |
|---|
| 20 | exit 1; |
|---|
| 21 | } |
|---|
| 22 | section = null; |
|---|
| 23 | } |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | /^msgid ".*"$/ { |
|---|
| 27 | $0 = gensub(/^msgid "(.*)"$/, "\\1", $0); |
|---|
| 28 | |
|---|
| 29 | section = "msgid"; |
|---|
| 30 | msgid = $0; |
|---|
| 31 | next; |
|---|
| 32 | } |
|---|
| 33 | /^msgstr ".*"$/ { |
|---|
| 34 | $0 = gensub(/^msgstr "(.*)"$/, "\\1", $0); |
|---|
| 35 | |
|---|
| 36 | section = "msgstr"; |
|---|
| 37 | msgstr = $0; |
|---|
| 38 | next; |
|---|
| 39 | } |
|---|
| 40 | /^".*"$/ { |
|---|
| 41 | $0 = gensub(/^"(.*)"$/, "\\1", $0); |
|---|
| 42 | if (section == "msgid") { |
|---|
| 43 | msgid = msgid $0; |
|---|
| 44 | } |
|---|
| 45 | else { |
|---|
| 46 | msgstr = msgstr $0; |
|---|
| 47 | } |
|---|
| 48 | next; |
|---|
| 49 | } |
|---|
| 50 | /^$/ { |
|---|
| 51 | flushOut(); |
|---|
| 52 | next; |
|---|
| 53 | } |
|---|
| 54 | /^#/ { |
|---|
| 55 | next; |
|---|
| 56 | } |
|---|
| 57 | /./ { |
|---|
| 58 | print "error", $0; |
|---|
| 59 | exit 1; |
|---|
| 60 | } |
|---|
| 61 | END { |
|---|
| 62 | flushOut(); |
|---|
| 63 | print ");"; |
|---|
| 64 | print ""; |
|---|
| 65 | } |
|---|