Changeset 153980 in webkit


Ignore:
Timestamp:
Aug 12, 2013 11:26:29 PM (11 years ago)
Author:
mitz@apple.com
Message:

extract-localizable-strings output is not suited for parsing by Xcode
https://bugs.webkit.org/show_bug.cgi?id=119728

Reviewed by Darin Adler.

Added spaces where needed after “path:line:” to allow Xcode to recognize the file reference,
removed “ERROR” since messages that refer to a line in a file are shown as error by default,
added “warning: ” in messages that aren’t errors (i.e. don’t prevent the script from exiting
with 0).

  • Scripts/extract-localizable-strings:
Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r153977 r153980  
     12013-08-12  Dan Bernstein  <mitz@apple.com>
     2
     3        extract-localizable-strings output is not suited for parsing by Xcode
     4        https://bugs.webkit.org/show_bug.cgi?id=119728
     5
     6        Reviewed by Darin Adler.
     7
     8        Added spaces where needed after “path:line:” to allow Xcode to recognize the file reference,
     9        removed “ERROR” since messages that refer to a line in a file are shown as error by default,
     10        added “warning: ” in messages that aren’t errors (i.e. don’t prevent the script from exiting
     11        with 0).
     12
     13        * Scripts/extract-localizable-strings:
     14
    1152013-08-12  Ryuan Choi  <ryuan.choi@samsung.com>
    216
  • trunk/Tools/Scripts/extract-localizable-strings

    r153976 r153980  
    9696        if (/^"([^\\"]|\\.)*"$/ or /^[-_\/\w\s.]+.(h|m|mm|c|cpp)$/ or /^[-_\/\w\s.]+.(h|m|mm|c|cpp):"([^\\"]|\\.)*"$/) {
    9797            if ($exception{$_}) {
    98                 print "$exceptionsFile:$.:exception for $_ appears twice\n";
    99                 print "$exceptionsFile:$exception{$_}:first appearance\n";
     98                print "$exceptionsFile:$.: warning: exception for $_ appears twice\n";
     99                print "$exceptionsFile:$exception{$_}: warning: first appearance\n";
    100100            } else {
    101101                $exception{$_} = $.;
    102102            }
    103103        } else {
    104             print "$exceptionsFile:$.:syntax error\n";
     104            print "$exceptionsFile:$.: warning: syntax error\n";
    105105        }
    106106    }
     
    152152            if ($token eq "\"") {
    153153                if ($expected and $expected ne "a quoted string") {
    154                     print "$file:$.:ERROR:found a quoted string but expected $expected\n";
     154                    print "$file:$.: found a quoted string but expected $expected\n";
    155155                    $sawError = 1;
    156156                    $expected = "";
     
    164164                    }
    165165                } else {
    166                     print "$file:$.:ERROR:mismatched quotes\n";
     166                    print "$file:$.: mismatched quotes\n";
    167167                    $sawError = 1;
    168168                    $_ = "";
     
    203203                        $usedException{"$file:\"$string\""} = 1;
    204204                    } else {
    205                         print "$file:$stringLine:\"$string\" is not marked for localization\n" if $warnAboutUnlocalizedStrings;
     205                        print "$file:$stringLine: warning: \"$string\" is not marked for localization\n" if $warnAboutUnlocalizedStrings;
    206206                        $notLocalizedCount++;
    207207                    }
     
    214214
    215215            if ($token =~ /^NSLocalized/ && $token !~ /NSLocalizedDescriptionKey/ && $token !~ /NSLocalizedStringFromTableInBundle/ && $token !~ /NSLocalizedFileSizeDescription/) {
    216                 print "$file:$.:ERROR:found a use of an NSLocalized macro ($token); not supported\n";
     216                print "$file:$.: found a use of an NSLocalized macro ($token); not supported\n";
    217217                $nestingLevel = 0 if !defined $nestingLevel;
    218218                $sawError = 1;
     
    227227            } elsif ($token eq "'") {
    228228                if (!s-([^\\]|\\.)'--) { #' <-- that single quote makes the Project Builder editor less confused
    229                     print "$file:$.:ERROR:mismatched single quote\n";
     229                    print "$file:$.: mismatched single quote\n";
    230230                    $sawError = 1;
    231231                    $_ = "";
     
    233233            } else {
    234234                if ($expected and $expected ne $token) {
    235                     print "$file:$.:ERROR:found $token but expected $expected\n";
     235                    print "$file:$.: found $token but expected $expected\n";
    236236                    $sawError = 1;
    237237                    $expected = "";
     
    269269   
    270270    if ($expected) {
    271         print "$file:ERROR:reached end of file but expected $expected\n";
     271        print "$file: reached end of file but expected $expected\n";
    272272        $sawError = 1;
    273273    }
     
    311311    $string = UnescapeHexSequence($string);
    312312    if (!defined($string)) {
    313         print "$file:$line:ERROR:string has an illegal hexadecimal escape sequence\n";
     313        print "$file:$line: string has an illegal hexadecimal escape sequence\n";
    314314        $bad = 1;
    315315    }
    316316    $key = UnescapeHexSequence($key);
    317317    if (!defined($key)) {
    318         print "$file:$line:ERROR:key has an illegal hexadecimal escape sequence\n";
     318        print "$file:$line: key has an illegal hexadecimal escape sequence\n";
    319319        $bad = 1;
    320320    }
    321321    $comment = UnescapeHexSequence($comment);
    322322    if (!defined($comment)) {
    323         print "$file:$line:ERROR:comment has an illegal hexadecimal escape sequence\n";
     323        print "$file:$line: comment has an illegal hexadecimal escape sequence\n";
    324324        $bad = 1;
    325325    }
    326326    if (grep { $_ == 0xFFFD } unpack "U*", $string) {
    327         print "$file:$line:ERROR:string for translation has illegal UTF-8 -- most likely a problem with the Text Encoding of the source file\n";
     327        print "$file:$line: string for translation has illegal UTF-8 -- most likely a problem with the Text Encoding of the source file\n";
    328328        $bad = 1;
    329329    }
    330330    if ($string ne $key && grep { $_ == 0xFFFD } unpack "U*", $key) {
    331         print "$file:$line:ERROR:key has illegal UTF-8 -- most likely a problem with the Text Encoding of the source file\n";
     331        print "$file:$line: key has illegal UTF-8 -- most likely a problem with the Text Encoding of the source file\n";
    332332        $bad = 1;
    333333    }
    334334    if (grep { $_ == 0xFFFD } unpack "U*", $comment) {
    335         print "$file:$line:ERROR:comment for translation has illegal UTF-8 -- most likely a problem with the Text Encoding of the source file\n";
     335        print "$file:$line: comment for translation has illegal UTF-8 -- most likely a problem with the Text Encoding of the source file\n";
    336336        $bad = 1;
    337337    }
     
    342342   
    343343    if ($stringByKey{$key} && $stringByKey{$key} ne $string) {
    344         print "$file:$line:encountered the same key, \"$key\", twice, with different strings\n";
    345         print "$fileByKey{$key}:$lineByKey{$key}:previous occurrence\n";
     344        print "$file:$line: warning: encountered the same key, \"$key\", twice, with different strings\n";
     345        print "$fileByKey{$key}:$lineByKey{$key}: warning: previous occurrence\n";
    346346        $keyCollisionCount++;
    347347        return;
    348348    }
    349349    if ($commentByKey{$key} && $commentByKey{$key} ne $comment) {
    350         print "$file:$line:encountered the same key, \"$key\", twice, with different comments\n";
    351         print "$fileByKey{$key}:$lineByKey{$key}:previous occurrence\n";
     350        print "$file:$line: warning: encountered the same key, \"$key\", twice, with different comments\n";
     351        print "$fileByKey{$key}:$lineByKey{$key}: warning: previous occurrence\n";
    352352        $keyCollisionCount++;
    353353        return;
     
    365365if (@unusedExceptions) {
    366366    for my $unused (@unusedExceptions) {
    367         print "$exceptionsFile:$exception{$unused}:exception $unused not used\n";
     367        print "$exceptionsFile:$exception{$unused}: warning: exception $unused not used\n";
    368368    }
    369369    print "\n";
     
    397397
    398398        my $lastComment;
     399        my $line;
    399400
    400401        while (<STRINGS>) {
     
    409410                my $string = delete $stringByKey{$1};
    410411                if (!defined $string) {
    411                     print "error: $fileToUpdate contains unused key \"$1\" (preceding comment: /* $lastComment */)\n";
     412                    print "$fileToUpdate:$.: unused key \"$1\" (preceding comment: /* $lastComment */)\n";
    412413                    $sawError = 1;
    413414                } else {
    414415                    if (!($string eq $2)) {
    415                         print "error: $fileToUpdate contains unexpected value \"$2\" for key \"$1\" (expected \"$string\")\n";
     416                        print "$fileToUpdate:$.: unexpected value \"$2\" for key \"$1\" (expected \"$string\")\n";
    416417                        $sawError = 1;
    417418                    }
    418419                    if (!($lastComment eq $commentByKey{$1})) {
    419                         print "error: $fileToUpdate contains unexpected comment /* $lastComment */ for key \"$1\" (expected /* $commentByKey{$1} */)\n";
     420                        print "$fileToUpdate:$.: unexpected comment /* $lastComment */ for key \"$1\" (expected /* $commentByKey{$1} */)\n";
     421                        $sawError = 1;
    420422                    }
    421423                }
    422424            } else {
    423                 print "error: $fileToUpdate contains line with unexpected format: $_\n";
     425                print "$fileToUpdate:$.: line with unexpected format: $_\n";
    424426                $sawError = 1;
    425427            }
     
    427429
    428430        for my $missing (keys %stringByKey) {
    429             print "error: $fileToUpdate is missing key \"$missing\"\n";
     431            print "$fileByKey{$missing}:$lineByKey{$missing}: missing key \"$missing\"\n";
    430432            $sawError = 1;
    431433        }
    432434
    433435        if ($sawError) {
    434             print "\nerror: $fileToUpdate is not up to date.\n";
     436            print "\n$fileToUpdate:0: file is not up to date.\n";
    435437            exit 1;
    436438        }
    437439    }
    438440} else {
    439     print "$fileToUpdate does not exist\n";
     441    print "error: $fileToUpdate does not exist\n";
    440442    exit 1;
    441443}
Note: See TracChangeset for help on using the changeset viewer.