#! /usr/local/bin/perl # -*- Perl -*- # Copyright (C) 2000 Motoyuki Kasahara # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. if (@ARGV != 1) { die "Usage: $0 po-file\n"; } $file_name = $ARGV[0]; # # Read the old message file. # if (!open(FILE, $file_name)) { die "$0: failed to open the file, $!: $file_name\n"; } $msgid = ''; while () { next if /^\#/; chop if /\n/; if (/^msgid:(.*)/) { $msgid = $1; if ($msgid eq '') { warn "$file_name:$.: msgid is empty\n"; next; } elsif (defined($old_messages{$msgid})) { warn "$file_name:$.: msgid redefined: $msgid"; next; } $old_messages{$msgid} = ''; } elsif (/^msgstr:(.*)/) { $msgstr = $1; if ($msgid eq '') { warn "$file_name:$.: msgid is empty\n"; next; } elsif ($msgstr eq '') { warn "$file_name:$.: msgstr is empty\n"; next; } $fixed_msgid = $msgid; $fixed_msgid =~ s/ /\\ /g; $old_messages{$msgid} = $msgstr; print "set messages($fixed_msgid) \"$msgstr\"\n"; } } close(FILE);