Changeset 5608
- Timestamp:
- 06/26/09 11:58:59 (3 years ago)
- Location:
- trunk/Locale-Msgfmt
- Files:
-
- 3 edited
-
Changes (modified) (1 diff)
-
lib/Locale/Msgfmt/po.pm (modified) (4 diffs)
-
t/msgfmt.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Locale-Msgfmt/Changes
r5607 r5608 3 3 0.06 Jun 26, 2009 4 4 add support for contexts 5 add support for ngettext 5 6 6 7 0.05 Jun 25, 2009 -
trunk/Locale-Msgfmt/lib/Locale/Msgfmt/po.pm
r5607 r5608 29 29 return if !(defined($h{msgid}) && defined($h{msgstr})); 30 30 return if ($h{fuzzy} && !$self->{fuzzy} && length($h{msgid}) > 0); 31 return if($h{msgstr} eq ""); 31 my $msgstr = join Locale::Msgfmt::Utils::null(), @{$h{msgstr}}; 32 return if($msgstr eq ""); 32 33 my $context; 34 my $plural; 33 35 if($h{msgctxt}) { 34 36 $context = cleanup_string($h{msgctxt}) . Locale::Msgfmt::Utils::eot(); … … 36 38 $context = ""; 37 39 } 38 $self->{mo}->add_string($context . cleanup_string($h{msgid}), cleanup_string($h{msgstr})); 40 if($h{msgid_plural}) { 41 $plural = Locale::Msgfmt::Utils::null() . cleanup_string($h{msgid_plural}); 42 } else { 43 $plural = ""; 44 } 45 $self->{mo}->add_string($context . cleanup_string($h{msgid}) . $plural, cleanup_string($msgstr)); 39 46 } 40 47 … … 48 55 while (<F>) { 49 56 s/\r\n/\n/; 50 if(/^(msgid |msgstr|msgctxt) +"(.*)" *$/) {57 if(/^(msgid(?:|_plural)|msgctxt) +"(.*)" *$/) { 51 58 $type = $1; 52 59 if(defined($h{$type})) { … … 56 63 $h{$type} = $2; 57 64 } 65 elsif(/^msgstr(?:\[(\d*)\])? +"(.*)" *$/) { 66 $type = "msgstr"; 67 if(!$h{$type}) { 68 @{$h{$type}} = (); 69 } 70 push @{$h{$type}}, $2; 71 } 58 72 elsif(/^"(.*)" *$/) { 59 $h{$type} .= $1; 73 if($type eq "msgstr") { 74 @{$h{$type}}[scalar(@{$h{$type}}) - 1] .= $1; 75 } else { 76 $h{$type} .= $1; 77 } 60 78 } 61 79 elsif(/^ *$/) { -
trunk/Locale-Msgfmt/t/msgfmt.t
r5607 r5608 32 32 do_one_test("fr-fr"); 33 33 do_one_test("context"); 34 TODO: { 35 local $TODO = "not yet implemented"; 36 37 do_one_test("ngettext"); 38 } 34 do_one_test("ngettext"); 39 35 } 40 36
Note: See TracChangeset
for help on using the changeset viewer.
