#!/usr/bin/perl # derived from MsgFormat.pl # # (C) 1998 Mike Shoyher # # patch from: Gunther Heintzen eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; # not running under some shell use strict; use DB_File; use vars qw{$locale_dir $lang %msg $path $s $msgid}; $locale_dir=$ARGV[0]; $lang=$ARGV[1]; my $path="$locale_dir/$lang"; printUsage() unless ($locale_dir && $lang); dbmopen(%msg, $path, 0644) || die "Cannot create database $path"; for () { if (/^msgid\s+\"(.*)\"\s*$/) { if ($msgid) { $msgid =~ s/\\n/\n/g; $s =~ s/\\n/\n/g; $s =~ s/\\"/"/g; print "MSGID: $msgid\nMSGSTR: $s"; if ($msgid ne $s && !defined($msg{$msgid})) { $msg{$msgid}=$s; print " ok\n"; } else { print " skipped\n"; } } $s=$1; } if (/^\"(.+)\"\s*$/) { $s.=$1; } if (/^msgstr\s+\"(.*)\"\s*$/) { $msgid = $s; $s = $1; } } $msgid=~s/\\n/\n/g; $s=~s/\\n/\n/g; $s=~s/\\"/"/g; print "MSGID: $msgid\nMSGSTR: $s\n"; $msg{$msgid}=$s if $msgid ne $s && !defined($msg{$msgid}); dbmclose(%msg); sub printUsage { print "Usage: MsgFormat < myprog.po\n\n"; exit(100); } =head1 NAME MsgFormat - messages database compiler for PGetText =head1 SYNOPSIS MsgFormat < myprog.po =head1 DESCRIPTION MsgFormat creates database in directory with messages from for language =head1 SEE ALSO Locale::PGetText =cut