WebKit2 needs to be made localizable
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2011 19:41:03 +0000 (19:41 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2011 19:41:03 +0000 (19:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=55483

Reviewed by Timothy Hatcher.

Source/WebCore:

* English.lproj/Localizable.strings: Copied from Source/WebKit/English.lproj/Localizable.strings.
* WebCore.xcodeproj/project.pbxproj:
Move Localizable.strings to WebCore.

* WebCore.exp.in:
Add export for localizedString function.

* platform/LocalizedStrings.h:
* platform/mac/LocalizedStringsMac.mm: Added.
Add function to get localized version of a string from the WebCore bundle.

Source/WebKit:

* StringsNotToBeLocalized.txt: Removed.
* WebKit.xcodeproj/project.pbxproj:
Copied Localizable.strings to WebCore, it can't be removed entirely
yet since Windows is still using it.

Source/WebKit/mac:

* WebCoreSupport/WebPlatformStrategies.mm:
Use WebCore's localizedString function instead of WebLocalizableStrings
since WebCore is now responsible for localization.

Source/WebKit2:

* PluginProcess/mac/PluginProcessMainMac.mm:
* WebProcess/mac/WebProcessMainMac.mm:
Set the default localization from the passed in parameter.

* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
Add the preferred localization as a parameter when launching processes
so that they can set their localization to match the launching app.

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
Use WebCore's localizedString function on the mac, to actually localize
these strings.

(WebKit::WebPlatformStrategies::imageTitle):
Switch to using replace, instead of concatenation, to give localizers a chance
to rearrange the wording.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80014 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings [new file with mode: 0644]
Source/WebCore/StringsNotToBeLocalized.txt [moved from Source/WebKit/StringsNotToBeLocalized.txt with 100% similarity]
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/mac/LocalizedStringsMac.mm [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm
Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm

index 0d835b4555eaffe6ba424ee9fc680a6885f14d40..2307a40efdc65846cab06d53afddbe65188cefe3 100644 (file)
@@ -1,4 +1,22 @@
-2011-02-23  Joseph Pecoraro  <joepeck@webkit.org>
+2011-03-01  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        WebKit2 needs to be made localizable
+        https://bugs.webkit.org/show_bug.cgi?id=55483
+
+        * English.lproj/Localizable.strings: Copied from Source/WebKit/English.lproj/Localizable.strings.
+        * WebCore.xcodeproj/project.pbxproj:
+        Move Localizable.strings to WebCore.
+
+        * WebCore.exp.in:
+        Add export for localizedString function.
+
+        * platform/LocalizedStrings.h:
+        * platform/mac/LocalizedStringsMac.mm: Added.
+        Add function to get localized version of a string from the WebCore bundle.
+
+2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>
 
         Reviewed by Kenneth Rohde Christiansen.
 
diff --git a/Source/WebCore/English.lproj/Localizable.strings b/Source/WebCore/English.lproj/Localizable.strings
new file mode 100644 (file)
index 0000000..2019d1d
Binary files /dev/null and b/Source/WebCore/English.lproj/Localizable.strings differ
index 99b5e84492d85de53726466d2f682b4a4c0c82eb..1c751ab5640e52d3e9e4bc1119e5e71b2b374bc0 100644 (file)
@@ -412,6 +412,7 @@ __ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontE
 __ZN7WebCore15VisiblePositionC1EPNS_4NodeEiNS_9EAffinityE
 __ZN7WebCore15VisiblePositionC1ERKNS_8PositionENS_9EAffinityE
 __ZN7WebCore15defaultLanguageEv
+__ZN7WebCore15localizedStringEPKc
 __ZN7WebCore15reportExceptionEPN3JSC9ExecStateENS0_7JSValueE
 __ZN7WebCore15visitedLinkHashEPKtj
 __ZN7WebCore16AbstractDatabase14setIsAvailableEb
index 2ba68f6e5338f163d6a081f4f34c8be8e41dae58..40d69b91073d0e4b7165f788f76d8ffe6b2ea50e 100644 (file)
                BC23EE920DAED2BC009FDC91 /* CSSImageGeneratorValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC23EE910DAED2BC009FDC91 /* CSSImageGeneratorValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC23F0DB0DAFF4A4009FDC91 /* GeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */; };
                BC2441C40E8B65D00055320F /* ScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2441C30E8B65D00055320F /* ScrollView.cpp */; };
+               BC25B52A131C6D3900180E10 /* LocalizedStringsMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC25B528131C6D3900180E10 /* LocalizedStringsMac.mm */; };
                BC275B7911C5D1C300C9206C /* JSWebKitPointCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC275B7811C5D1C300C9206C /* JSWebKitPointCustom.cpp */; };
                BC275B7D11C5D23500C9206C /* JSWebKitCSSMatrixCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC275B7C11C5D23500C9206C /* JSWebKitCSSMatrixCustom.cpp */; };
                BC275B8111C5D2B400C9206C /* JSEventSourceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC275B8011C5D2B400C9206C /* JSEventSourceCustom.cpp */; };
                BCAA90C30A7EBA60008B1229 /* Scrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */; };
                BCACF3BC1072921A00C0C8A3 /* UserContentURLPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */; };
                BCACF3BD1072921A00C0C8A3 /* UserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               BCAD180A131C7A0D00990406 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BCAD1808131C7A0D00990406 /* Localizable.strings */; };
                BCAE1FA712939DB7004CB026 /* ScrollAnimatorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */; };
                BCAEFCAE1016CE4A0040D34E /* DOMRGBColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCAEFCAD1016CE4A0040D34E /* DOMRGBColor.mm */; };
                BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */; };
                BC23EE910DAED2BC009FDC91 /* CSSImageGeneratorValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSImageGeneratorValue.h; sourceTree = "<group>"; };
                BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedImage.h; sourceTree = "<group>"; };
                BC2441C30E8B65D00055320F /* ScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollView.cpp; sourceTree = "<group>"; };
+               BC25B528131C6D3900180E10 /* LocalizedStringsMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedStringsMac.mm; sourceTree = "<group>"; };
                BC275B7811C5D1C300C9206C /* JSWebKitPointCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitPointCustom.cpp; sourceTree = "<group>"; };
                BC275B7C11C5D23500C9206C /* JSWebKitCSSMatrixCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitCSSMatrixCustom.cpp; sourceTree = "<group>"; };
                BC275B8011C5D2B400C9206C /* JSEventSourceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventSourceCustom.cpp; sourceTree = "<group>"; };
                BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Scrollbar.cpp; sourceTree = "<group>"; };
                BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentURLPattern.cpp; sourceTree = "<group>"; };
                BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentURLPattern.h; sourceTree = "<group>"; };
+               BCAD1809131C7A0D00990406 /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
                BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimatorMac.h; sourceTree = "<group>"; };
                BCAEFCAD1016CE4A0040D34E /* DOMRGBColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMRGBColor.mm; sourceTree = "<group>"; };
                BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryCache.cpp; sourceTree = "<group>"; };
                089C1665FE841158C02AAC07 /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               BCAD1808131C7A0D00990406 /* Localizable.strings */,
                                46F9D5DA0B0D60170028EE36 /* aliasCursor.png */,
                                46D4F2460AF97E810035385A /* cellCursor.png */,
                                46D4F2470AF97E810035385A /* contextMenuCursor.png */,
                                9352084409BD43B900F2038D /* Language.mm */,
                                06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
                                06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */,
+                               BC25B528131C6D3900180E10 /* LocalizedStringsMac.mm */,
                                1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
                                BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */,
                                A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
                        buildActionMask = 2147483647;
                        files = (
                                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
+                               BCAD180A131C7A0D00990406 /* Localizable.strings in Resources */,
                                46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
                                46D4F24A0AF97E810035385A /* contextMenuCursor.png in Resources */,
                                4614A1FE0B23A8D600446E1C /* copyCursor.png in Resources */,
                                93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
                                977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
+                               BC25B52A131C6D3900180E10 /* LocalizedStringsMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
 /* End PBXTargetDependency section */
 
 /* Begin PBXVariantGroup section */
+               BCAD1808131C7A0D00990406 /* Localizable.strings */ = {
+                       isa = PBXVariantGroup;
+                       children = (
+                               BCAD1809131C7A0D00990406 /* English */,
+                       );
+                       name = Localizable.strings;
+                       sourceTree = "<group>";
+               };
                BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */ = {
                        isa = PBXVariantGroup;
                        children = (
index 561bbe6de59daa4e0345844cdfff89d6c6f8a4fe..7ef301cc61d35e7a7936b8a9867b78bf416f5b83 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2009 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2003, 2006, 2009, 2011 Apple Inc.  All rights reserved.
  * Copyright (C) 2010 Igalia S.L
  *
  * Redistribution and use in source and binary forms, with or without
@@ -187,6 +187,10 @@ namespace WebCore {
     String validationMessageRangeOverflowText(const String& maximum);
     String validationMessageStepMismatchText(const String& base, const String& step);
 
-}
-
+#if PLATFORM(MAC)
+    String localizedString(const char* key);
 #endif
+
+} // namespace WebCore
+
+#endif // LocalizedStrings_h
diff --git a/Source/WebCore/platform/mac/LocalizedStringsMac.mm b/Source/WebCore/platform/mac/LocalizedStringsMac.mm
new file mode 100644 (file)
index 0000000..2dc44e9
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "LocalizedStrings.h"
+
+#import <wtf/Assertions.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Threading.h>
+#import <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+String localizedString(const char* key)
+{
+    static NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
+
+    ASSERT(isMainThread());
+    
+    RetainPtr<CFStringRef> keyString(AdoptCF, CFStringCreateWithCStringNoCopy(NULL, key, kCFStringEncodingUTF8, kCFAllocatorNull));
+    NSString *notFound = @"localized string not found";
+    NSString *result = [bundle localizedStringForKey:(NSString *)keyString.get() value:notFound table:nil];
+
+    ASSERT_WITH_MESSAGE(result != notFound, "could not find localizable string %s in bundle", key);
+    return result;
+}
+
+} // namespace WebCore
index 7ccdf2785e68c9e1aa9452f762e9681ea8d30fdf..4f1c07696f4c05cf41468eb7190f741ad5f03ebe 100644 (file)
@@ -1,3 +1,15 @@
+2011-03-01  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        WebKit2 needs to be made localizable
+        https://bugs.webkit.org/show_bug.cgi?id=55483
+
+        * StringsNotToBeLocalized.txt: Removed.
+        * WebKit.xcodeproj/project.pbxproj:
+        Copied Localizable.strings to WebCore, it can't be removed entirely
+        yet since Windows is still using it.
+
 2011-02-24  Peter Kasting  <pkasting@google.com>
 
         Reviewed by Eric Seidel.
index 649bf1683869275171c4f4469c2e8a931668c51b..1ee1d7e1f93e0b06d41ec945fa7247bddc5f50e0 100644 (file)
                5D7BF8140C2A1D90008CE06D /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D7BF8120C2A1D90008CE06D /* WebInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5D7BF8150C2A1D90008CE06D /* WebInspector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5D7BF8130C2A1D90008CE06D /* WebInspector.mm */; };
                5DE83A7A0D0F7F9400CAD12A /* WebJavaScriptTextInputPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = 5DE83A740D0F7F9400CAD12A /* WebJavaScriptTextInputPanel.nib */; };
-               5DE83A7F0D0F7FAD00CAD12A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5DE83A7D0D0F7FAD00CAD12A /* Localizable.strings */; };
                5DE92FEF0BD7017E0059A5FD /* WebAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DE92FEE0BD7017E0059A5FD /* WebAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65488DA1084FBCCB00831AD0 /* WebNSDictionaryExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 65488D9F084FBCCB00831AD0 /* WebNSDictionaryExtras.h */; };
                65488DA2084FBCCB00831AD0 /* WebNSDictionaryExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 65488DA0084FBCCB00831AD0 /* WebNSDictionaryExtras.m */; };
                5D7BF8120C2A1D90008CE06D /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; };
                5D7BF8130C2A1D90008CE06D /* WebInspector.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspector.mm; sourceTree = "<group>"; };
                5DE83A750D0F7F9400CAD12A /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/WebJavaScriptTextInputPanel.nib; sourceTree = SOURCE_ROOT; };
-               5DE83A7E0D0F7FAD00CAD12A /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
                5DE92FEE0BD7017E0059A5FD /* WebAssertions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebAssertions.h; sourceTree = "<group>"; };
                65488D9F084FBCCB00831AD0 /* WebNSDictionaryExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSDictionaryExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                65488DA0084FBCCB00831AD0 /* WebNSDictionaryExtras.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSDictionaryExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED21B9810528F7AA003299AC /* WebDocumentInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDocumentInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED2B2474033A2DA800C1A526 /* WebNSPasteboardExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSPasteboardExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED2B2475033A2DA800C1A526 /* WebNSPasteboardExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNSPasteboardExtras.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               ED3B48DE0CC51F7E00DFF1EB /* StringsNotToBeLocalized.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = StringsNotToBeLocalized.txt; sourceTree = SOURCE_ROOT; };
                ED5B9523111B725A00472298 /* WebLocalizableStrings.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebLocalizableStrings.mm; sourceTree = "<group>"; };
                ED6BE2E5088C32B50044DEDC /* WebNSAttributedStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSAttributedStringExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED6BE2E6088C32B50044DEDC /* WebNSAttributedStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNSAttributedStringExtras.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                        children = (
                                9325FBDC07D829AE00159862 /* IDNScriptWhiteList.txt */,
                                939811320824BF01008DF038 /* Info.plist */,
-                               5DE83A7D0D0F7FAD00CAD12A /* Localizable.strings */,
-                               ED3B48DE0CC51F7E00DFF1EB /* StringsNotToBeLocalized.txt */,
                                F5B67130023EDF8901C1A525 /* url_icon.tiff */,
                                5DE83A740D0F7F9400CAD12A /* WebJavaScriptTextInputPanel.nib */,
                        );
                        files = (
                                A864B3F6123ED9FA00C2A612 /* MailQuirksUserScript.js in Resources */,
                                939810BA0824BF01008DF038 /* IDNScriptWhiteList.txt in Resources */,
-                               5DE83A7F0D0F7FAD00CAD12A /* Localizable.strings in Resources */,
                                939810B70824BF01008DF038 /* url_icon.tiff in Resources */,
                                939810B50824BF01008DF038 /* WebAuthenticationPanel.nib in Resources */,
                                5DE83A7A0D0F7F9400CAD12A /* WebJavaScriptTextInputPanel.nib in Resources */,
                        path = mac/Resources;
                        sourceTree = SOURCE_ROOT;
                };
-               5DE83A7D0D0F7FAD00CAD12A /* Localizable.strings */ = {
-                       isa = PBXVariantGroup;
-                       children = (
-                               5DE83A7E0D0F7FAD00CAD12A /* English */,
-                       );
-                       name = Localizable.strings;
-                       path = mac/Resources;
-                       sourceTree = SOURCE_ROOT;
-               };
                9345D17B0365BF35008635CE /* WebAuthenticationPanel.nib */ = {
                        isa = PBXVariantGroup;
                        children = (
index bff011be6057623b132cda63151c577fc1cd0317..f659a0b1b47f455738749bedff10b077d09c3e0e 100644 (file)
@@ -1,3 +1,14 @@
+2011-03-01  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        WebKit2 needs to be made localizable
+        https://bugs.webkit.org/show_bug.cgi?id=55483
+
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        Use WebCore's localizedString function instead of WebLocalizableStrings
+        since WebCore is now responsible for localization.
+
 2011-02-25 Steve Block <steveblock@google.com>
 
         Reviewed by Jeremy Orlow.
index 8f81cdcba286e2304692cb2acd9069f16e960dfb..35fba5e7aef1ba5423e6daddd92ea7a8cdf683a1 100644 (file)
 
 #import "WebPlatformStrategies.h"
 
-#import "WebLocalizableStrings.h"
 #import "WebPluginDatabase.h"
 #import "WebPluginPackage.h"
 #import <WebCore/BlockExceptions.h>
 #import <WebCore/IntSize.h>
+#import <WebCore/LocalizedStrings.h>
 #import <WebCore/Page.h>
 #import <WebCore/PageGroup.h>
 #import <wtf/StdLibExtras.h>
 
-#ifdef BUILDING_ON_TIGER
-typedef unsigned NSUInteger;
-#endif
+#define UI_STRING(string, description) localizedString(string)
+#define UI_STRING_KEY(string, key, description) localizedString(key)
 
 using namespace WebCore;
 
index 517793181e63ef633eb48e5a047e3b71048e532c..4e825af1b95354801a127fb88fa1ed728fe393d5 100644 (file)
@@ -1,3 +1,26 @@
+2011-03-01  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        WebKit2 needs to be made localizable
+        https://bugs.webkit.org/show_bug.cgi?id=55483
+
+        * PluginProcess/mac/PluginProcessMainMac.mm:
+        * WebProcess/mac/WebProcessMainMac.mm:
+        Set the default localization from the passed in parameter.
+
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        Add the preferred localization as a parameter when launching processes
+        so that they can set their localization to match the launching app.
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        Use WebCore's localizedString function on the mac, to actually localize
+        these strings.
+
+        (WebKit::WebPlatformStrategies::imageTitle):
+        Switch to using replace, instead of concatenation, to give localizers a chance
+        to rearrange the wording.
+
 2011-03-01  Balazs Kelemen  <kbalazs@webkit.org>
 
         Reviewed by Anders Carlsson.
index d39353ad3241de393287d4c64b9cc67ae63bbc98..5bb80a2725d9e471acd435731efac85b9d459511 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import "CommandLine.h"
 #import "PluginProcess.h"
 #import "RunLoop.h"
+#import <WebKitSystemInterface.h>
 #import <runtime/InitializeThreading.h>
 #import <servers/bootstrap.h>
+#import <wtf/RetainPtr.h>
 #import <wtf/text/CString.h>
 #import <wtf/text/WTFString.h>
-#import <WebKitSystemInterface.h>
 
 // FIXME: We should be doing this another way.
 extern "C" kern_return_t bootstrap_look_up2(mach_port_t, const name_t, mach_port_t*, pid_t, uint64_t);
@@ -64,7 +65,12 @@ int PluginProcessMain(const CommandLine& commandLine)
         printf("bootstrap_look_up2 result: %x", kr);
         return EXIT_FAILURE;
     }
-    
+
+    String localization = commandLine["localization"];
+    RetainPtr<CFStringRef> cfLocalization(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(localization.characters()), localization.length()));
+    if (cfLocalization)
+        WKSetDefaultLocalization(cfLocalization.get());
+
 #if !SHOW_CRASH_REPORTER
     // Installs signal handlers that exit on a crash so that CrashReporter does not show up.
     signal(SIGILL, _exit);
index be7962d0f0ee030e8a4df715bcb60a3d6955702a..af758d96b13bd0a45080b42bca966419e9bc63dc 100644 (file)
@@ -203,10 +203,13 @@ void ProcessLauncher::launchProcess()
     NSString *webProcessAppPath = [webKit2Bundle pathForAuxiliaryExecutable:@"WebProcess.app"];
     NSString *webProcessAppExecutablePath = [[NSBundle bundleWithPath:webProcessAppPath] executablePath];
 
+    RetainPtr<CFStringRef> cfLocalization(AdoptCF, WKCopyCFLocalizationPreferredName(NULL));
+    CString localization = String(cfLocalization.get()).utf8();
+    
     // Make a unique, per pid, per process launcher web process service name.
     CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8();
 
-    const char* args[] = { [webProcessAppExecutablePath fileSystemRepresentation], frameworkExecutablePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), 0 };
+    const char* args[] = { [webProcessAppExecutablePath fileSystemRepresentation], frameworkExecutablePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), "-localization", localization.data(), 0 };
 
     // Register ourselves.
     kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0);
index a4e75e20eb8da715c6c51ec99ef60b07c304afa6..c202285ffb8e0dd630a930086a01b5c7a331915e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
 #include "WebContextMessages.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
+#include <WebCore/LocalizedStrings.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
 #include <WebCore/PageGroup.h>
 #include <wtf/RetainPtr.h>
 #endif
 
-// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
+#if PLATFORM(MAC)
+
+#define UI_STRING(string, description) localizedString(string)
+#define UI_STRING_KEY(string, key, description) localizedString(key)
+
+#else
+
 #define UI_STRING(string, description) String::fromUTF8(string, strlen(string))
 #define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string))
 
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -753,8 +762,8 @@ String WebPlatformStrategies::allFilesText()
 
 String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size)
 {
-    // FIXME: It would be nice to have the filename inside the format string, but it's not easy to do that in a way that works with non-ASCII characters in the filename.
-    return filename + formatLocalizedString(UI_STRING(" %d×%d pixels", "window title suffix for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height());
+    // FIXME: This should format the numbers correctly. In Mac WebKit, we used +[NSNumberFormatter localizedStringFromNumber:numberStyle:].
+    return formatLocalizedString(UI_STRING("<filename> %d×%d pixels", "window title suffix for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()).replace("<filename>", filename);
 }
 
 String WebPlatformStrategies::mediaElementLoadingStateText()
index 846d7a1df1c1d2eda9d1f8617d463bc1593e25c7..6469df236b28d3208fb6f0ce6ff6d9fd471646b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -72,6 +72,11 @@ int WebProcessMain(const CommandLine& commandLine)
         return 2;
     }
 
+    String localization = commandLine["localization"];
+    RetainPtr<CFStringRef> cfLocalization(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(localization.characters()), localization.length()));
+    if (cfLocalization)
+        WKSetDefaultLocalization(cfLocalization.get());
+
 #if !SHOW_CRASH_REPORTER
     // Installs signal handlers that exit on a crash so that CrashReporter does not show up.
     signal(SIGILL, _exit);