Changeset 153976 in webkit
- Timestamp:
- Aug 12, 2013 10:53:05 PM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r153973 r153976 1 2013-08-12 Dan Bernstein <mitz@apple.com> 2 3 extract-localizable-strings doesn't know how to verify an existing strings file 4 https://bugs.webkit.org/show_bug.cgi?id=119704 5 6 Reviewed by Darin Adler. 7 8 * Scripts/extract-localizable-strings: Added an --exceptions option for specifying the 9 exceptions file, changing the way “no exceptions file” is expressed from passing “-” as the 10 exceptions file name to omitting the --exceptions option. Added a --skip option, changing 11 the way directories to skip are specified from prefixing the directory with a “-” to 12 specifying it with --skip. 13 Finally, added a --verify option. When specified, the strings file is not written to, but 14 instead read in and checked for consistency with the comments, keys and values derived from 15 the source files and the exceptions file. Missing keys, unused keys, mismatching values and 16 mismatching comments are reported as errors. 17 * Scripts/update-webkit-localizable-strings: Updated for the new way of specifying 18 directories to skip and no exceptions file. 19 1 20 2013-08-12 Alexey Proskuryakov <ap@apple.com> 2 21 -
trunk/Tools/Scripts/extract-localizable-strings
r153348 r153976 44 44 45 45 use strict; 46 use Getopt::Long; 46 47 no warnings 'deprecated'; 47 48 … … 50 51 my %isDebugMacro = ( ASSERT_WITH_MESSAGE => 1, LOG_ERROR => 1, ERROR => 1, NSURL_ERROR => 1, FATAL => 1, LOG => 1, LOG_WARNING => 1, UI_STRING_LOCALIZE_LATER => 1, UI_STRING_LOCALIZE_LATER_KEY => 1, LPCTSTR_UI_STRING_LOCALIZE_LATER => 1, UNLOCALIZED_STRING => 1, UNLOCALIZED_LPCTSTR => 1, dprintf => 1, NSException => 1, NSLog => 1, printf => 1 ); 51 52 52 @ARGV >= 2 or die "Usage: extract-localizable-strings <exceptions file> <file to update> [ directory... ]\nDid you mean to run update-webkit-localizable-strings instead?\n"; 53 54 my $exceptionsFile = shift @ARGV; 55 -f $exceptionsFile or die "Couldn't find exceptions file $exceptionsFile\n" unless $exceptionsFile eq "-"; 53 my $verify; 54 my $exceptionsFile; 55 my @directoriesToSkip = (); 56 57 my %options = ( 58 'verify' => \$verify, 59 'exceptions=s' => \$exceptionsFile, 60 'skip=s' => \@directoriesToSkip, 61 ); 62 63 GetOptions(%options); 64 65 @ARGV >= 2 or die "Usage: extract-localizable-strings [--verify] [--exceptions <exceptions file>] <file to update> [--skip directory | directory]...\nDid you mean to run update-webkit-localizable-strings instead?\n"; 66 67 -f $exceptionsFile or die "Couldn't find exceptions file $exceptionsFile\n" unless !defined $exceptionsFile; 56 68 57 69 my $fileToUpdate = shift @ARGV; 58 70 -f $fileToUpdate or die "Couldn't find file to update $fileToUpdate\n"; 59 71 60 my $warnAboutUnlocalizedStrings = $exceptionsFile ne "-";72 my $warnAboutUnlocalizedStrings = defined $exceptionsFile; 61 73 62 74 my @directories = (); 63 my @directoriesToSkip = ();64 75 if (@ARGV < 1) { 65 76 push(@directories, "."); 66 77 } else { 67 78 for my $dir (@ARGV) { 68 if ($dir =~ /^-(.*)$/) { 69 push @directoriesToSkip, $1; 70 } else { 71 push @directories, $dir; 72 } 79 push @directories, $dir; 73 80 } 74 81 } … … 84 91 my %usedException; 85 92 86 if ( $exceptionsFile ne "-"&& open EXCEPTIONS, $exceptionsFile) {93 if (defined $exceptionsFile && open EXCEPTIONS, $exceptionsFile) { 87 94 while (<EXCEPTIONS>) { 88 95 chomp; … … 380 387 } 381 388 382 # Write out the strings file as UTF-8383 389 if (-e "$fileToUpdate") { 384 open STRINGS, ">", "$fileToUpdate" or die; 385 print STRINGS $localizedStrings; 386 close STRINGS; 390 if (!$verify) { 391 # Write out the strings file as UTF-8 392 open STRINGS, ">", "$fileToUpdate" or die; 393 print STRINGS $localizedStrings; 394 close STRINGS; 395 } else { 396 open STRINGS, $fileToUpdate or die; 397 398 my $lastComment; 399 400 while (<STRINGS>) { 401 chomp; 402 403 next if (/^\s*$/); 404 405 if (/^\/\* (.*) \*\/$/) { 406 $lastComment = $1; 407 } elsif (/^"((?:[^\\]|\\[^"])*)"\s*=\s*"((?:[^\\]|\\[^"])*)";$/) # 408 { 409 my $string = delete $stringByKey{$1}; 410 if (!defined $string) { 411 print "error: $fileToUpdate contains unused key \"$1\" (preceding comment: /* $lastComment */)\n"; 412 $sawError = 1; 413 } else { 414 if (!($string eq $2)) { 415 print "error: $fileToUpdate contains unexpected value \"$2\" for key \"$1\" (expected \"$string\")\n"; 416 $sawError = 1; 417 } 418 if (!($lastComment eq $commentByKey{$1})) { 419 print "error: $fileToUpdate contains unexpected comment /* $lastComment */ for key \"$1\" (expected /* $commentByKey{$1} */)\n"; 420 } 421 } 422 } else { 423 print "error: $fileToUpdate contains line with unexpected format: $_\n"; 424 $sawError = 1; 425 } 426 } 427 428 for my $missing (keys %stringByKey) { 429 print "error: $fileToUpdate is missing key \"$missing\"\n"; 430 $sawError = 1; 431 } 432 433 if ($sawError) { 434 print "\nerror: $fileToUpdate is not up to date.\n"; 435 exit 1; 436 } 437 } 387 438 } else { 388 439 print "$fileToUpdate does not exist\n"; -
trunk/Tools/Scripts/update-webkit-localizable-strings
r152870 r153976 36 36 37 37 # WebKit and WebKit2 strings go into WebCore's Localizable.strings. 38 my @webKitDirectoriesToScan = ("Source/WebCore", "Source/WebKit/mac", "Source/WebKit/win", "Source/WebKit2", "- Source/WebCore/icu", "-Source/WebKit/mac/icu");38 my @webKitDirectoriesToScan = ("Source/WebCore", "Source/WebKit/mac", "Source/WebKit/win", "Source/WebKit2", "--skip", "Source/WebCore/icu", "--skip", "Source/WebKit/mac/icu"); 39 39 my @webInspectorUIDirectoriesToScan = ("Source/WebInspectorUI/UserInterface"); 40 40 … … 46 46 chdirWebKit(); 47 47 48 system "Tools/Scripts/extract-localizable-strings", "-",$webCoreFileToUpdate, @webKitDirectoriesToScan;48 system "Tools/Scripts/extract-localizable-strings", $webCoreFileToUpdate, @webKitDirectoriesToScan; 49 49 system "Tools/Scripts/extract-localizable-js-strings", $webInspectorUIFileToUpdate, @webInspectorUIDirectoriesToScan;
Note: See TracChangeset
for help on using the changeset viewer.