X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=po%2Fpocheck.pl;h=391245a11ebc2ef672c2ff7f0943a38b001bcd19;hb=44e88a4c1324fed447ab5510734c741d18f856c0;hp=1cd3a8c94e6e1a5f5790c5c1e734189526515b45;hpb=f4c3dc66687a69cdd1f9cddea53d74875de2695c;p=lyx.git diff --git a/po/pocheck.pl b/po/pocheck.pl index 1cd3a8c94e..391245a11e 100755 --- a/po/pocheck.pl +++ b/po/pocheck.pl @@ -12,13 +12,17 @@ use strict; use warnings; use Getopt::Std; +use Encode qw(encode decode); + +sub mylc($); +sub replaceSynopsis($); my $usage = < '$msgstr'\n" unless $only_total; @@ -171,7 +179,7 @@ foreach my $pofilename ( @ARGV ) { if ($check_qt) { # Check for "&" shortcuts - if ( ( $msgid =~ m/&[^ ]/ ) != ( $msgstr =~ m/&[^ ]/ ) ) { + if ( ( $msgid =~ m/&[^ &]/ ) != ( $msgstr =~ m/&[^ &]/ ) ) { print "Line $linenum: Missing or unexpected Qt shortcut:\n '$msgid' => '$msgstr'\n" unless $only_total; ++$bad{"Bad Qt shortcuts"}; @@ -194,8 +202,8 @@ foreach my $pofilename ( @ARGV ) { # we now collect these translations in a hash. # this will allow us to check below if we have translated # anything more than one way. - my $msgid_clean = lc($msgid); - my $msgstr_clean = lc($msgstr); + my $msgid_clean = lc($msgid_trans); + my $msgstr_clean = mylc($msgstr); $msgid_clean =~ s/(.*)\|.*?$/$1/; # strip menu shortcuts $msgstr_clean =~ s/(.*)\|.*?$/$1/; @@ -206,7 +214,7 @@ foreach my $pofilename ( @ARGV ) { # cleaned versions of ORIGINAL strings. the keys of the inner hash # are the cleaned versions of their TRANSLATIONS. The value for the # inner hash is an array of the orignal string and translation. - $trans{$msgid_clean}{$msgstr_clean} = [ $msgid, $msgstr, $linenum ]; + $trans{$msgid_clean}{$msgstr_clean} = [ $msgid_trans, $msgstr, $linenum ]; } if ($check_trans) { @@ -247,3 +255,19 @@ foreach my $pofilename ( @ARGV ) { exit ($total_warn > 0); +# Use lowercase also for non-ascii chars +sub mylc($) +{ + my ($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"); +}