pocheck.pl: In checking for period at end, treat '...' be equivalent to '…'

This commit is contained in:
Kornel Benko 2017-12-26 10:45:44 +01:00
parent 713fd70e8f
commit 626f607db7

View File

@ -15,6 +15,7 @@ use Getopt::Std;
use Encode qw(encode decode); use Encode qw(encode decode);
sub mylc($); sub mylc($);
sub replaceSynopsis($);
my $usage = <<EOT; my $usage = <<EOT;
pocheck.pl [-acmpqst] po_file [po_file] ... pocheck.pl [-acmpqst] po_file [po_file] ...
@ -155,6 +156,9 @@ foreach my $pofilename ( @ARGV ) {
if ($check_periods) { if ($check_periods) {
# Check period at the end of a message; uncomment code if you are paranoid # Check period at the end of a message; uncomment code if you are paranoid
# Convert '...' to '…' first
$msgid = replaceSynopsis($msgid);
$msgstr = replaceSynopsis($msgstr);
if ( ( $msgid =~ m/\. *(\|.*)?$/ ) != ( $msgstr =~ m/\. *(\|.*)?$/ ) ) { if ( ( $msgid =~ m/\. *(\|.*)?$/ ) != ( $msgstr =~ m/\. *(\|.*)?$/ ) ) {
print "Line $linenum: Missing or unexpected period:\n '$msgid' => '$msgstr'\n" print "Line $linenum: Missing or unexpected period:\n '$msgid' => '$msgstr'\n"
unless $only_total; unless $only_total;
@ -257,3 +261,13 @@ sub mylc($)
my ($msg) = @_; my ($msg) = @_;
return(encode('utf-8',lc(decode('utf-8', $msg)))); return(encode('utf-8',lc(decode('utf-8', $msg))));
} }
sub replaceSynopsis($)
{
my ($string) = @_;
return ($string) if ($string !~ /^(.*)\.\.\.(.*)$/);
my ($before, $after) = ($1, $2);
return $string if (($before =~ /\.$/) || ($after =~ /^\./));
return("$before…$after");
}