Changeset 74306 in webkit


Ignore:
Timestamp:
Dec 17, 2010 5:42:54 PM (13 years ago)
Author:
Darin Adler
Message:

2010-12-17 Darin Adler <Darin Adler>

Reviewed by Dan Bernstein.

Window title for image documents shows corrupted characters instead of multiplication sign when using WebKit2
https://bugs.webkit.org/show_bug.cgi?id=43505

  • WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: Changed UI_STRING macros to return WebCore::String objects instead of C strings. (WebKit::formatLocalizedString): Added. Uses the Core Foundation string formatting function for reasons explained in the comment. (WebKit::WebPlatformStrategies::multipleFileUploadText): Use formatLocalizedString instead of String::format. (WebKit::WebPlatformStrategies::imageTitle): Ditto. (WebKit::WebPlatformStrategies::localizedMediaTimeDescription): Ditto.
Location:
trunk/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r74303 r74306  
     12010-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
    1172010-12-17  Anders Carlsson  <andersca@apple.com>
    218
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp

    r71655 r74306  
    3939
    4040// FIXME: Implement localization.
    41 #define UI_STRING(string, description) string
    42 #define UI_STRING_KEY(string, key, description) string
     41#define UI_STRING(string, description) String::fromUTF8(string, strlen(string))
     42#define UI_STRING_KEY(string, key, description) String::fromUTF8(string, strlen(string))
    4343
    4444using namespace WebCore;
    4545
    4646namespace 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.
     51static 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}
    4765
    4866void WebPlatformStrategies::initialize()
     
    680698String WebPlatformStrategies::multipleFileUploadText(unsigned numberOfFiles)
    681699{
    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);
    683701}
    684702
     
    706724String WebPlatformStrategies::imageTitle(const String& filename, const IntSize& size)
    707725{
    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());
    709728}
    710729
     
    821840
    822841    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);
    824843    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);
    826845    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);
    829848}
    830849
Note: See TracChangeset for help on using the changeset viewer.