aboutsummaryrefslogtreecommitdiffstats
path: root/posubst.in
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:05:14 +0000
committerTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:05:14 +0000
commit72f72d64a422d6628c4796f5c0bf2e508f134214 (patch)
tree0c9ea90cc53310832c977265521fb44db24a515e /posubst.in
parentAdding upstream version 0.3 (diff)
downloadw3m-72f72d64a422d6628c4796f5c0bf2e508f134214.tar.gz
w3m-72f72d64a422d6628c4796f5c0bf2e508f134214.zip
Adding upstream version 0.5.1upstream/0.5.1
Diffstat (limited to 'posubst.in')
-rw-r--r--posubst.in53
1 files changed, 53 insertions, 0 deletions
diff --git a/posubst.in b/posubst.in
new file mode 100644
index 0000000..a2c445f
--- /dev/null
+++ b/posubst.in
@@ -0,0 +1,53 @@
+#!@PERL@
+# gettext message substitute
+#
+$po_dir='po';
+$lang='@POLANG@';
+%msg = ();
+$msgid = '';
+$charset = "UTF-8";
+$charset_code = "WC_CES_UTF_8";
+open(PO, "$po_dir/$lang.po") or die "cannot open $po_dir/$lang.po, $!";
+while (<PO>) {
+ if (/^msgid\s*"(.*)"/) {
+ $msgid = $1;
+ next;
+ }
+ if (/^msgstr\s*"(.*)"/) {
+ $msg{$msgid} = $1;
+ next;
+ }
+ if (/^"Content-Type: text\/plain; charset=(.*)\\n"/) {
+ $charset = $1;
+ next;
+ }
+}
+close(PO);
+open(CL, "charset-list") or die "cannot open charset-list, $!";
+while (<CL>) {
+ @l = split;
+ if ($l[0] eq $charset) {
+ $charset_code = $l[1];
+ last;
+ }
+}
+close(CL);
+
+@src = grep {/\.c$/} @ARGV;
+@tmp = ();
+foreach $src (@src) {
+ open(SRC0, $src) or die "cannot open $src, $!";
+ push(@tmp, ".$src");
+ open(SRC1, ">.$src") or die "cannot create .$src, $!";
+ while (<SRC0>) {
+ s/^static\s*wc_ces\s*(\S+)\s*=\s*(WC_CES_\S+)\s*;\s*\/\*\s*FIXME: charset of source code \*\//static wc_ces $1 = $charset_code; \/* FIXME: charset of source code *\//;
+ s/(N?_\(")([^"]*)("\))/$1 . ($msg{$2} || $2) . $3/ge;
+ print SRC1 $_;
+ }
+ close(SRC0);
+ close(SRC1);
+}
+
+map {s/(.*\.c)$/.$1/} @ARGV;
+system @ARGV;
+unlink @tmp;