Changeset 74306 in webkit
- Timestamp:
- Dec 17, 2010 5:42:54 PM (13 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r74303 r74306 1 2010-12-17 Darin Adler <darin@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 Window title for image documents shows corrupted characters instead of multiplication sign when using WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=43505 7 8 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: Changed UI_STRING macros to return 9 WebCore::String objects instead of C strings. 10 (WebKit::formatLocalizedString): Added. Uses the Core Foundation string formatting function for 11 reasons explained in the comment. 12 (WebKit::WebPlatformStrategies::multipleFileUploadText): Use formatLocalizedString instead of 13 String::format. 14 (WebKit::WebPlatformStrategies::imageTitle): Ditto. 15 (WebKit::WebPlatformStrategies::localizedMediaTimeDescription): Ditto. 16 1 17 2010-12-17 Anders Carlsson <andersca@apple.com> 2 18 -
trunk/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r71655 r74306 39 39 40 40 // FIXME: Implement localization. 41 #define UI_STRING(string, description) string42 #define UI_STRING_KEY(string, key, description) string41 #define UI_STRING(string, description) String::fromUTF8(string, strlen(string)) 42 #define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string)) 43 43 44 44 using namespace WebCore; 45 45 46 46 namespace WebKit { 47 48 // We can't use String::format for two reasons: 49 // 1) It doesn't handle non-ASCII characters in the format string. 50 // 2) It doesn't handle the %2$d syntax. 51 static String formatLocalizedString(const String& format, ...) 52 { 53 #if PLATFORM(CF) 54 va_list arguments; 55 va_start(arguments, format); 56 RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString()); 57 RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments)); 58 va_end(arguments); 59 return result.get(); 60 #else 61 notImplemented(); 62 return format; 63 #endif 64 } 47 65 48 66 void WebPlatformStrategies::initialize() … … 680 698 String WebPlatformStrategies::multipleFileUploadText(unsigned numberOfFiles) 681 699 { 682 return String::format(UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles);700 return formatLocalizedString(UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles); 683 701 } 684 702 … … 706 724 String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size) 707 725 { 708 return String::format(UI_STRING("%s %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename.utf8().data(), size.width(), size.height()); 726 // 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. 727 return filename + formatLocalizedString(UI_STRING(" %d×%d pixels", "window title suffix for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()); 709 728 } 710 729 … … 821 840 822 841 if (days) 823 return String::format(UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds);842 return formatLocalizedString(UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds); 824 843 if (hours) 825 return String::format(UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds);844 return formatLocalizedString(UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds); 826 845 if (minutes) 827 return String::format(UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds);828 return String::format(UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds);846 return formatLocalizedString(UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds); 847 return formatLocalizedString(UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds); 829 848 } 830 849
Note: See TracChangeset
for help on using the changeset viewer.