Changeset 84033 in webkit
- Timestamp:
- Apr 15, 2011 2:18:20 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84029 r84033 1 2011-04-15 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Adam Roben. 4 5 Implement localize strings for windows WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=58688 7 8 * platform/win/LocalizedStringsWin.cpp: 9 (WebCore::createWebKitBundle): 10 (WebCore::webKitBundle): 11 (WebCore::localizedString): 12 Add implementation of localizedString for Windows. 13 1 14 2011-04-15 Geoffrey Garen <ggaren@apple.com> 2 15 -
trunk/Source/WebCore/platform/win/LocalizedStringsWin.cpp
r82465 r84033 27 27 #include "LocalizedStrings.h" 28 28 29 #include "WebCoreInstanceHandle.h" 30 #include <CoreFoundation/CFBundle.h> 31 #include <wtf/Assertions.h> 32 #include <wtf/RetainPtr.h> 33 #include <wtf/StdLibExtras.h> 34 #include <wtf/Threading.h> 29 35 #include <wtf/text/WTFString.h> 30 36 31 37 namespace WebCore { 32 38 39 static CFBundleRef createWebKitBundle() 40 { 41 if (CFBundleRef existingBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"))) { 42 CFRetain(existingBundle); 43 return existingBundle; 44 } 45 46 wchar_t dllPathBuffer[MAX_PATH]; 47 DWORD length = ::GetModuleFileNameW(instanceHandle(), dllPathBuffer, WTF_ARRAY_LENGTH(dllPathBuffer)); 48 ASSERT(length); 49 ASSERT(length < WTF_ARRAY_LENGTH(dllPathBuffer)); 50 51 RetainPtr<CFStringRef> dllPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(dllPathBuffer), length, kCFAllocatorNull)); 52 RetainPtr<CFURLRef> dllURL(AdoptCF, CFURLCreateWithFileSystemPath(0, dllPath.get(), kCFURLWindowsPathStyle, false)); 53 RetainPtr<CFURLRef> dllDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, dllURL.get())); 54 RetainPtr<CFURLRef> resourcesDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, dllDirectoryURL.get(), CFSTR("WebKit.resources"), true)); 55 56 return CFBundleCreate(0, resourcesDirectoryURL.get()); 57 } 58 59 static CFBundleRef webKitBundle() 60 { 61 static CFBundleRef bundle = createWebKitBundle(); 62 ASSERT(bundle); 63 return bundle; 64 } 65 33 66 String localizedString(const char* key) 34 67 { 35 // FIXME: <rdar://problem/9119405> Win: WebKit2 needs to be made localizable 36 return String::fromUTF8(key, strlen(key)); 68 ASSERT(isMainThread()); 69 70 static CFStringRef notFound = CFSTR("localized string not found"); 71 72 RetainPtr<CFStringRef> keyString(AdoptCF, CFStringCreateWithCStringNoCopy(NULL, key, kCFStringEncodingUTF8, kCFAllocatorNull)); 73 RetainPtr<CFStringRef> result(AdoptCF, CFCopyLocalizedStringWithDefaultValue(keyString.get(), 0, webKitBundle(), notFound, 0)); 74 ASSERT_WITH_MESSAGE(result.get() != notFound, "could not find localizable string %s in bundle", key); 75 76 return result.get(); 37 77 } 38 78
Note: See TracChangeset
for help on using the changeset viewer.