summaryrefslogtreecommitdiff
path: root/themes/upstream/po/bin/fixpot
blob: 1ed96654f72e2e209fd8279fd63d09c7a5a7f477 (plain)
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
#! /usr/bin/perl

while(<>) {
  if(/^\s*#|^\s*$/) { $msg[$cnt]{comment} .= $_; next }
  if(s/^\s*msgid\b\s*//) { $cnt++; $id = 1 }
  if(s/^\s*msgstr\b\s*//) { $id = 2 }
  if($id == 1) { $msg[$cnt - 1]{id} .= $_; next }
  if($id == 2) { $msg[$cnt - 1]{str} .= $_; next }

  die "oops at line $.\n";
}

for (@msg) {
  print $_->{comment};

  next unless defined($_->{id}) && defined($_->{str});

  if($_->{id} =~ /^\s*""\s*$/ || $_->{str} =~ /^\s*""\s*$/) {
    print "msgid ", $_->{id};
    print "msgstr ", $_->{str};
  }
  else {
    print "msgid ", $_->{str};
    print "msgstr \"\"\n";
  }
}