summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/extract-localizable-strings
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/Scripts/extract-localizable-strings')
-rwxr-xr-xWebKitTools/Scripts/extract-localizable-strings36
1 files changed, 14 insertions, 22 deletions
diff --git a/WebKitTools/Scripts/extract-localizable-strings b/WebKitTools/Scripts/extract-localizable-strings
index 15d6782..420624b 100755
--- a/WebKitTools/Scripts/extract-localizable-strings
+++ b/WebKitTools/Scripts/extract-localizable-strings
@@ -44,14 +44,16 @@
use strict;
-my $stringsFile = "English.lproj/Localizable.strings";
-my %isDebugMacro = ( ASSERT_WITH_MESSAGE => 1, LOG_ERROR => 1, ERROR => 1, NSURL_ERROR => 1, FATAL => 1, LOG => 1, dprintf => 1, NSException => 1, NSLog => 1, printf => 1 );
+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, LPCTSTR_UI_STRING_LOCALIZE_LATER => 1, UNLOCALIZED_STRING => 1, UNLOCALIZED_LPCTSTR => 1, dprintf => 1, NSException => 1, NSLog => 1, printf => 1 );
@ARGV >= 1 or die "Usage: extract-localizable-strings <exceptions file> [ directory... ]\nDid you mean to run extract-webkit-localizable-strings instead?\n";
my $exceptionsFile = shift @ARGV;
-f $exceptionsFile or die "Couldn't find exceptions file $exceptionsFile\n";
+my $fileToUpdate = shift @ARGV;
+-f $fileToUpdate or die "Couldn't find file to update $fileToUpdate\n";
+
my @directories = ();
my @directoriesToSkip = ();
if (@ARGV < 1) {
@@ -164,7 +166,7 @@ handleString:
# FIXME: Validate UTF-8 here?
$UIString = $string;
$expected = ",";
- } elsif (($macro eq "UI_STRING_KEY" or $macro eq "LPCTSTR_UI_STRING_KEY") and !defined $key) {
+ } elsif (($macro =~ /UI_STRING_KEY$/) and !defined $key) {
# FIXME: Validate UTF-8 here?
$key = $string;
$expected = ",";
@@ -223,7 +225,7 @@ handleString:
$sawError = 1;
$expected = "";
}
- if ($token eq "UI_STRING" or $token eq "UI_STRING_KEY" or $token eq "LPCTSTR_UI_STRING" or $token eq "LPCTSTR_UI_STRING_KEY") {
+ if ($token =~ /UI_STRING(_KEY)?$/) {
$expected = "(";
$macro = $token;
$UIString = undef;
@@ -325,7 +327,7 @@ print "$NSLocalizeCount uses of NSLocalize\n" if $NSLocalizeCount;
print scalar(@unusedExceptions), " unused exceptions\n" if @unusedExceptions;
if ($sawError) {
- print "\nErrors encountered. Exiting without writing a $stringsFile file.\n";
+ print "\nErrors encountered. Exiting without writing to $fileToUpdate.\n";
exit 1;
}
@@ -338,22 +340,12 @@ for my $key (sort keys %commentByKey) {
# Write out the strings file in UTF-16 with a BOM.
utf8::decode($localizedStrings) if $^V ge chr(5).chr(8);
my $output = pack "n*", (0xFEFF, unpack "U*", $localizedStrings);
-foreach my $directory (@directories) {
- if (-e "$directory/mac/$stringsFile") {
- open STRINGS, ">", "$directory/mac/$stringsFile" or die;
- print STRINGS $output;
- close STRINGS;
- }
-
- if (-e "$directory/win/$stringsFile") {
- open STRINGS, ">", "$directory/win/$stringsFile" or die;
- print STRINGS $output;
- close STRINGS;
- }
- if (-e "$directory/$stringsFile") {
- open STRINGS, ">", "$directory/$stringsFile" or die;
- print STRINGS $output;
- close STRINGS;
- }
+if (-e "$fileToUpdate") {
+ open STRINGS, ">", "$fileToUpdate" or die;
+ print STRINGS $output;
+ close STRINGS;
+} else {
+ print "$fileToUpdate does not exist\n";
+ exit 1;
}