From f0a9c930a9e16efb964190cdb9059610668b098e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 24 Feb 2010 20:49:45 -0600 Subject: pretty major rewrite, now based on Locale::Maketext::Lexicon --- lib/Locale/POFileManager.pm | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lib/Locale/POFileManager.pm') diff --git a/lib/Locale/POFileManager.pm b/lib/Locale/POFileManager.pm index b32b076..54317ca 100644 --- a/lib/Locale/POFileManager.pm +++ b/lib/Locale/POFileManager.pm @@ -154,9 +154,8 @@ sub stub_msgstr { my %args = @_; my $canonical_msgstr; $canonical_msgstr = - $weakself->canonical_language_file->entry_for($args{msgid})->msgstr + $weakself->canonical_language_file->msgstr($args{msgid}) if $weakself; - $canonical_msgstr =~ s/^"|"$//g if defined($canonical_msgstr); return $msgstr->( %args, defined($canonical_msgstr) ? (canonical_msgstr => $canonical_msgstr) : (), @@ -200,13 +199,26 @@ sub add_language { confess("Can't overwrite existing language file for $lang") if -e $file->stringify; + my $canon_pofile = $self->canonical_language_file; + + my $fh = $file->openw; + $fh->binmode(':utf8'); + $fh->print(qq{msgid ""\n}); + $fh->print(qq{msgstr ""\n}); + for my $header_key ($canon_pofile->headers) { + $fh->print(qq{"$header_key: } + . $canon_pofile->header($header_key) + . qq{\\n"\n}); + } + $fh->print(qq{\n}); + $fh->close; + my $msgstr = $self->stub_msgstr; my $pofile = Locale::POFileManager::File->new( file => $file, defined($msgstr) ? (stub_msgstr => $msgstr) : (), ); - $pofile->add_entry($self->canonical_language_file->entry_for('')); - $pofile->save; + $self->_add_file($pofile); } -- cgit v1.2.3-54-g00ecf