1#!/usr/bin/perl 2 3# 4# ...because it's easier to write my own internationalization 5# support than understanding gnu gettext and all the incompatibilities 6# between its versions 7# 8 9my $msgcount = 0; 10 11my $id = ""; 12my $msg = ""; 13 14my $state = 0; 15 16while($_=<>) { 17 chomp; 18 19 if ($state == 0) { 20 if (/^msgid\s+\"(.*)\"/) { 21 $id = $1; 22 $msg = ""; 23 $state = 1; 24 next; 25 } 26 next; 27 } 28 29 if ($state == 1) { 30 if (/^\"(.*)\"/) { 31 $id = "$id$1"; 32 next; 33 } 34 if (/^msgstr\s+\"(.*)\"/) { 35 $msg = $1; 36 $state = 2; 37 next; 38 } 39 next; 40 } 41 42 if ($state == 2) { 43 if (/^\"(.*)\"/) { 44 $msg = "$msg$1"; 45 next; 46 } 47 48 $id =~ s/\\"/"/g; 49 $msg =~ s/\\"/"/g; 50 51 $idlen = length($id); 52 $msglen = length($msg); 53 if ($idlen > 0 && $msglen > 0) { 54 $msgcount++; 55 print "L$idlen $msglen\n"; 56 print "$id\n"; 57 print "$msg\n"; 58 } 59 $state = 0; 60 next; 61 } 62} 63 64if ($state != 0) { 65 $idlen = length($id); 66 $msglen = length($msg); 67 if ($idlen > 0 && $msglen > 0) { 68 $msgcount++; 69 print "L$idlen $msglen\n"; 70 print "$id\n"; 71 print "$msg\n"; 72 } 73} 74 75print "E $msgcount\n"; 76 77 78