i18n: add a fixup script for pidgin-sipe.pot
[siplcs.git] / po / transifex-pot-fixup.pl
blob95b1cfb0058b486973d00aa42b4098e1a9701d35
1 #!/usr/bin/perl -w
3 # Fix up pidgin-sipe.pot after an update with intltool-update --pot
4 # This is required to make it acceptable for Transifex
6 use 5.008;
7 use strict;
8 use warnings;
10 open(my $fh, "+<", "pidgin-sipe.pot")
11 or die "$0: can't open POT file: $!\n";
13 my $date;
15 my(undef, $min, $hour, $mday, $mon, $year) = gmtime(time());
16 $date = sprintf("%4d-%02d-%02d %02d:%02d+0000",
17 $year + 1900, $mon + 1, $mday, $hour, $min);
20 # Must be 19 lines (same as header created by intltool-update)
21 my @lines = ( <<"END_OF_HEADER"
22 # (English) English User Interface strings for pidgin-sipe.
23 # Copyright (C) 2008-2011 SIPE Project <http://sipe.sourceforge.net/>
24 # This file is distributed under the same license as the pidgin-sipe package.
28 msgid ""
29 msgstr ""
30 "Project-Id-Version: pidgin sipe\\n"
31 "Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?group_id=194563&atid=949931\\n"
32 "POT-Creation-Date: 2010-11-30 23:36+0200\\n"
33 "PO-Revision-Date: $date\\n"
34 "Last-Translator: stefanb <chemobejk\@gmail.com>\\n"
35 "Language-Team: English <LL\@li.org>\\n"
36 "MIME-Version: 1.0\\n"
37 "Content-Type: text/plain; charset=UTF-8\\n"
38 "Content-Transfer-Encoding: 8bit\\n"
39 "Language: en\\n"
40 "Plural-Forms: nplurals=2; plural=(n != 1)\\n"
41 END_OF_HEADER
44 my $lastid = "";
45 my $multiline;
46 while (<$fh>) {
47 # skip header
48 next if $. < 20;
50 # Copy original text from msgid to msgstr
51 if (/^msgstr ("")$/) {
52 if ($multiline) {
53 push(@lines, qq{msgstr ""\n}, $lastid);
54 $multiline = 0;
55 } else {
56 push(@lines, qq{msgstr "$lastid"\n});
58 next;
59 } elsif ($multiline) {
60 $lastid .= $_;
61 } elsif (/^msgid "(.*)"$/) {
62 $lastid = $1;
63 $multiline = 1 if $lastid eq "";
66 push(@lines, $_);
69 # Update pot file
70 seek($fh, 0, 0)
71 or die "$0: can't rewind POT file: $!\n";
72 print $fh @lines;
73 close($fh)
74 or die "$0: can't write to POT file: $!\n";
76 # That's all folks
77 exit 0;