Changeset c7267bc in git


Ignore:
Timestamp:
06/03/15 00:42:36 (5 years ago)
Author:
Olly Betts <olly@…>
Branches:
line_contents, master, stereo, travis-osx
Children:
2d8b140
Parents:
4b5971f
Message:

lib/po-to-msg.pl: Add check that language code in file matches the
filename.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r4b5971f rc7267bc  
     1Fri Mar 06 00:42:21 GMT 2015  Olly Betts <olly@survex.com>
     2
     3        * lib/po-to-msg.pl: Add check that language code in file matches the
     4          filename.
     5
    16Thu Mar 05 23:53:33 GMT 2015  Olly Betts <olly@survex.com>
    27
  • lib/po-to-msg.pl

    r4b5971f rc7267bc  
    7070    $file = "$srcdir/$po_file";
    7171    my $po_hash = Locale::PO->load_file_ashash($file);
     72
     73    if (exists $$po_hash{'""'}) {
     74        if ($$po_hash{'""'}->msgstr =~ /^(?:.*\\n)?Language:\s*([^\s\\]+)/im) {
     75            if ($language ne $1) {
     76                my $line = 3 + scalar(@{[$& =~ /(\\n)/g]});
     77                print STDERR "$file:$line: Language code '$1' doesn't match '$language' from filename\n";
     78            }
     79        } else {
     80            my $line = 2 + scalar(@{[$$po_hash{'""'}->msgstr =~ /(\\n)/g]});
     81            print STDERR "$file:$line: No suitable 'Language:' field in header\n";
     82        }
     83    } else {
     84        print STDERR "$file:1: Expected 'msgid \"\"' with header\n";
     85    }
    7286
    7387    foreach my $po_entry (@{$num_list}) {
Note: See TracChangeset for help on using the changeset viewer.