Log Message
Compiler should be able to check localized format strings for consistency <https://webkit.org/b/232686> <rdar://problem/84994345>
Reviewed by Darin Adler. Source/WebCore: The primary goal of this patch is to allow the compiler to check format strings to ensure that the correct number and type of arguments and placeholders are used. The epiphany to make this possible was that Apple platforms may use CFStringRef objects or const char* C-strings to accomplish this with CoreFoundation macros. Non-Apple platforms continue to use const char* for format strings to allow the compiler to check format strings. To this end localized strings passed to formatLocalizedString() must use a WEB_UI_FORMAT_*() macro on all platforms. Failure to do so will result in a compiler error, though, since non-FORMAT macros return a WTF::String. This patch also eliminates autoreleased NSString objects except when using WEB_UI_NSSTRING()/localizedNSString() directly (the return value is always autoreleased), and it removes the need to convert from CF/NSString -> WTF::String -> CF/NSString for localized format strings. * Scripts/extract-localizable-strings.pl: (isFormatMacro): Add. - Add support for parsing the following new macros with variadic parameter lists: o WEB_UI_FORMAT_STRING [cross-platform] o WEB_UI_FORMAT_CFSTRING o WEB_UI_FORMAT_CFSTRING_KEY * platform/LocalizedStrings.cpp: (WebCore::formatLocalizedString): - Implement using `CFStringRef format` for Apple platforms, but `const char* format` for other platforms. - Use of these types allows format checking macros to be added to declarations in LocalizedStrings.h. (WebCore::webCoreBundle): Add. - Extract code for getting a CFBundleRef for WebCore.framework into a function that's similar to webKitBundle() on Windows. (WebCore::copyLocalizedString): Add. - This method was converted from localizedNSString() in LocalizedStringsCocoa.mm and from localizedString() in LocalizedStringsWin.cpp. (WebCore::localizedString(CFStringRef)): Add. - Avoids runtime creation of CFStringRef on non-Windows platforms. (WebCore::localizedString(const char*)): - Code for USE(CF) was converted from the same method in LocalizedStringsCocoa.mm, but only used on Windows port. (WebCore::contextMenuItemTagLookUpInDictionary): (WebCore::contextMenuItemTagTranslate): (WebCore::multipleFileUploadText): (WebCore::imageTitle): (WebCore::localizedMediaTimeDescription): (WebCore::validationMessageTooShortText): (WebCore::validationMessageTooLongText): (WebCore::validationMessageRangeUnderflowText): (WebCore::validationMessageRangeOverflowText): (WebCore::addTrackLabelAsSuffix): (WebCore::addTextTrackKindClosedCaptionsSuffix): (WebCore::addTextTrackKindCaptionsSuffix): (WebCore::addTextTrackKindDescriptionsSuffix): (WebCore::addTextTrackKindChaptersSuffix): (WebCore::addTextTrackKindMetadataSuffix): (WebCore::addTextTrackKindSDHSuffix): (WebCore::addTextTrackKindEasyReaderSuffix): (WebCore::addTextTrackKindForcedSuffix): (WebCore::addAudioTrackKindDescriptionsSuffix): (WebCore::addAudioTrackKindCommentarySuffix): (WebCore::webCryptoMasterKeyKeychainLabel): (WebCore::makeCredentialTouchIDPromptTitle): (WebCore::getAssertionTouchIDPromptTitle): - Use WEB_UI_FORMAT_STRING() for cross-platform UI format strings, and use WEB_UI_FORMAT_CFSTRING[_KEY]() for Apple platform UI format strings. - Make formatLocalizedString() an implementation detail of WEB_UI_FORMAT_[CF]STRING() macros. * platform/LocalizedStrings.h: (WEB_UI_STRING): Add. (WEB_UI_STRING_KEY): Add. (WEB_UI_STRING_WITH_MNEMONIC): Add. (WEB_UI_CFSTRING): Add. (WEB_UI_CFSTRING_KEY): Add. - Add USE(CF)-specific macros to avoid CFStringRef allocations at runtime. The Apple Windows port can not use these because it uses a default encoding of Mac Roman for CFSTR(). (WEB_UI_FORMAT_STRING): Add. - Cross-platform macro for UI format strings. - Note that non-USE(CF) macros essentially do nothing since localizedString() just converts const char* to WTF::String (which was previously converted back to const char*), and formatLocalizedString() now takes a const char*. (WEB_UI_FORMAT_CFSTRING): Add. (WEB_UI_FORMAT_CFSTRING_KEY): Add. - These macros are used as format string arguments to formatLocalizedString(). (WebCore::localizedFormatString): Add. - Declare a new function for USE(CF) that is passed to formatLocalizedString(). (WebCore::localizedString(CFStringRef)): Add. - Declare a new function for USE(CF) that takes a CFStringRef argument. (WebCore::formatLocalizedString): - Change to use `CFStringRef format` for USE(CF) platforms (except Windows), and `const char* format` for other platforms so format macros may be added to the delaration. (WebCore::localizedNSString): - Re-implement as an inline function using localizedString(). * platform/cocoa/LocalizedStringsCocoa.mm: (WebCore::localizedNSString): Delete. - Moved to LocalizedStrings.h. (WebCore::localizedString): Delete. - Moved to LocalizedStrings.cpp. (WebCore::contextMenuItemTagSearchWeb): (WebCore::keygenKeychainItemName): (WebCore::htmlSelectMultipleItems): - Switch from WEB_UI_STRING() to WEB_UI_FORMAT_CFSTRING() due to the new rule for localized format strings. (WebCore::validationMessageTooLongText): - Switch from +[NSString stringWithFormat:] and WEB_UI_NSSTRING() to WebCore::formatLocalizedString() and WEB_UI_FORMAT_CFSTRING() for consistency. * platform/win/LocalizedStringsWin.cpp: (WebCore::localizedString): Delete. - Moved to localizedString() in LocalizedStrings.cpp. Source/WebCore/platform/gtk/po: * CMakeLists.txt: (add_custom_command: xgettext): - Add WEB_UI_FORMAT_STRING to list of macros containing localizable strings. Source/WebKitLegacy/mac: * Misc/WebLocalizableStringsInternal.mm: (WebLocalizedStringInternal): - Use localizedNSString() instead of localizedString() to eliminate the need to convert from CFString -> String -> NSString.
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/Scripts/extract-localizable-strings.pl
- trunk/Source/WebCore/platform/LocalizedStrings.cpp
- trunk/Source/WebCore/platform/LocalizedStrings.h
- trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm
- trunk/Source/WebCore/platform/gtk/po/CMakeLists.txt
- trunk/Source/WebCore/platform/gtk/po/ChangeLog
- trunk/Source/WebCore/platform/win/LocalizedStringsWin.cpp
- trunk/Source/WebKitLegacy/mac/ChangeLog
- trunk/Source/WebKitLegacy/mac/Misc/WebLocalizableStringsInternal.mm
Diff
Modified: trunk/Source/WebCore/ChangeLog (286155 => 286156)
--- trunk/Source/WebCore/ChangeLog 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/ChangeLog 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,3 +1,137 @@
+2021-11-24 David Kilzer <[email protected]>
+
+ Compiler should be able to check localized format strings for consistency
+ <https://webkit.org/b/232686>
+ <rdar://problem/84994345>
+
+ Reviewed by Darin Adler.
+
+ The primary goal of this patch is to allow the compiler to check
+ format strings to ensure that the correct number and type of
+ arguments and placeholders are used. The epiphany to make this
+ possible was that Apple platforms may use CFStringRef objects or
+ const char* C-strings to accomplish this with CoreFoundation
+ macros. Non-Apple platforms continue to use const char* for
+ format strings to allow the compiler to check format strings.
+
+ To this end localized strings passed to formatLocalizedString()
+ must use a WEB_UI_FORMAT_*() macro on all platforms. Failure to
+ do so will result in a compiler error, though, since non-FORMAT
+ macros return a WTF::String.
+
+ This patch also eliminates autoreleased NSString objects except
+ when using WEB_UI_NSSTRING()/localizedNSString() directly (the
+ return value is always autoreleased), and it removes the need to
+ convert from CF/NSString -> WTF::String -> CF/NSString for
+ localized format strings.
+
+ * Scripts/extract-localizable-strings.pl:
+ (isFormatMacro): Add.
+ - Add support for parsing the following new macros with variadic
+ parameter lists:
+ o WEB_UI_FORMAT_STRING [cross-platform]
+ o WEB_UI_FORMAT_CFSTRING
+ o WEB_UI_FORMAT_CFSTRING_KEY
+
+ * platform/LocalizedStrings.cpp:
+ (WebCore::formatLocalizedString):
+ - Implement using `CFStringRef format` for Apple platforms, but
+ `const char* format` for other platforms.
+ - Use of these types allows format checking macros to be added
+ to declarations in LocalizedStrings.h.
+ (WebCore::webCoreBundle): Add.
+ - Extract code for getting a CFBundleRef for WebCore.framework
+ into a function that's similar to webKitBundle() on Windows.
+ (WebCore::copyLocalizedString): Add.
+ - This method was converted from localizedNSString() in
+ LocalizedStringsCocoa.mm and from localizedString() in
+ LocalizedStringsWin.cpp.
+ (WebCore::localizedString(CFStringRef)): Add.
+ - Avoids runtime creation of CFStringRef on non-Windows
+ platforms.
+ (WebCore::localizedString(const char*)):
+ - Code for USE(CF) was converted from the same method in
+ LocalizedStringsCocoa.mm, but only used on Windows port.
+ (WebCore::contextMenuItemTagLookUpInDictionary):
+ (WebCore::contextMenuItemTagTranslate):
+ (WebCore::multipleFileUploadText):
+ (WebCore::imageTitle):
+ (WebCore::localizedMediaTimeDescription):
+ (WebCore::validationMessageTooShortText):
+ (WebCore::validationMessageTooLongText):
+ (WebCore::validationMessageRangeUnderflowText):
+ (WebCore::validationMessageRangeOverflowText):
+ (WebCore::addTrackLabelAsSuffix):
+ (WebCore::addTextTrackKindClosedCaptionsSuffix):
+ (WebCore::addTextTrackKindCaptionsSuffix):
+ (WebCore::addTextTrackKindDescriptionsSuffix):
+ (WebCore::addTextTrackKindChaptersSuffix):
+ (WebCore::addTextTrackKindMetadataSuffix):
+ (WebCore::addTextTrackKindSDHSuffix):
+ (WebCore::addTextTrackKindEasyReaderSuffix):
+ (WebCore::addTextTrackKindForcedSuffix):
+ (WebCore::addAudioTrackKindDescriptionsSuffix):
+ (WebCore::addAudioTrackKindCommentarySuffix):
+ (WebCore::webCryptoMasterKeyKeychainLabel):
+ (WebCore::makeCredentialTouchIDPromptTitle):
+ (WebCore::getAssertionTouchIDPromptTitle):
+ - Use WEB_UI_FORMAT_STRING() for cross-platform UI format
+ strings, and use WEB_UI_FORMAT_CFSTRING[_KEY]() for Apple
+ platform UI format strings.
+ - Make formatLocalizedString() an implementation detail of
+ WEB_UI_FORMAT_[CF]STRING() macros.
+
+ * platform/LocalizedStrings.h:
+ (WEB_UI_STRING): Add.
+ (WEB_UI_STRING_KEY): Add.
+ (WEB_UI_STRING_WITH_MNEMONIC): Add.
+ (WEB_UI_CFSTRING): Add.
+ (WEB_UI_CFSTRING_KEY): Add.
+ - Add USE(CF)-specific macros to avoid CFStringRef allocations
+ at runtime. The Apple Windows port can not use these because
+ it uses a default encoding of Mac Roman for CFSTR().
+ (WEB_UI_FORMAT_STRING): Add.
+ - Cross-platform macro for UI format strings.
+ - Note that non-USE(CF) macros essentially do nothing since
+ localizedString() just converts const char* to WTF::String
+ (which was previously converted back to const char*), and
+ formatLocalizedString() now takes a const char*.
+ (WEB_UI_FORMAT_CFSTRING): Add.
+ (WEB_UI_FORMAT_CFSTRING_KEY): Add.
+ - These macros are used as format string arguments to
+ formatLocalizedString().
+ (WebCore::localizedFormatString): Add.
+ - Declare a new function for USE(CF) that is passed to
+ formatLocalizedString().
+ (WebCore::localizedString(CFStringRef)): Add.
+ - Declare a new function for USE(CF) that takes a CFStringRef
+ argument.
+ (WebCore::formatLocalizedString):
+ - Change to use `CFStringRef format` for USE(CF) platforms
+ (except Windows), and `const char* format` for other platforms
+ so format macros may be added to the delaration.
+ (WebCore::localizedNSString):
+ - Re-implement as an inline function using localizedString().
+
+ * platform/cocoa/LocalizedStringsCocoa.mm:
+ (WebCore::localizedNSString): Delete.
+ - Moved to LocalizedStrings.h.
+ (WebCore::localizedString): Delete.
+ - Moved to LocalizedStrings.cpp.
+ (WebCore::contextMenuItemTagSearchWeb):
+ (WebCore::keygenKeychainItemName):
+ (WebCore::htmlSelectMultipleItems):
+ - Switch from WEB_UI_STRING() to WEB_UI_FORMAT_CFSTRING() due to
+ the new rule for localized format strings.
+ (WebCore::validationMessageTooLongText):
+ - Switch from +[NSString stringWithFormat:] and
+ WEB_UI_NSSTRING() to WebCore::formatLocalizedString() and
+ WEB_UI_FORMAT_CFSTRING() for consistency.
+
+ * platform/win/LocalizedStringsWin.cpp:
+ (WebCore::localizedString): Delete.
+ - Moved to localizedString() in LocalizedStrings.cpp.
+
2021-11-24 Said Abou-Hallawa <[email protected]>
[GPU Process] Move the software FilterEffectAppliers to separate files
Modified: trunk/Source/WebCore/Scripts/extract-localizable-strings.pl (286155 => 286156)
--- trunk/Source/WebCore/Scripts/extract-localizable-strings.pl 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/Scripts/extract-localizable-strings.pl 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-# Copyright (C) 2006, 2007, 2009, 2010, 2013 Apple Inc. All rights reserved.
+# Copyright (C) 2006-2021 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -118,6 +118,8 @@
my @files = ( split "\n", `find $quotedDirectoriesString \\( -name "*.h" -o -name "*.m" -o -name "*.mm" -o -name "*.c" -o -name "*.cpp" \\)` );
+sub isFormatMacro($) { return ($_[0] =~ /(WEB_)?UI_FORMAT_/); }
+
for my $file (sort @files) {
next if $file =~ /\/\w+LocalizableStrings\w*\.h$/ || $file =~ /\/LocalizedStrings\.h$/;
@@ -133,6 +135,7 @@
my $UIString;
my $key;
my $comment;
+ my $isFormat;
my $mnemonic;
my $string;
@@ -186,12 +189,14 @@
# FIXME: Validate UTF-8 here?
$UIString = $string;
$expected = ",";
- } elsif (($macro =~ /(WEB_)?UI_(CF)?STRING_KEY(_INTERNAL)?$/) and !defined $key) {
+ } elsif (($macro =~ /(WEB_)?UI_(FORMAT_)?(CF)?STRING_KEY(_INTERNAL)?$/) and !defined $key) {
# FIXME: Validate UTF-8 here?
$key = $string;
+ $isFormat = isFormatMacro($macro);
$expected = ",";
} elsif (($macro =~ /WEB_UI_STRING_WITH_MNEMONIC$/) and !defined $mnemonic) {
$mnemonic = $string;
+ $isFormat = 0;
$expected = ",";
} elsif (!defined $comment) {
# FIXME: Validate UTF-8 here?
@@ -241,11 +246,11 @@
$_ = "";
}
} else {
- if ($expected and $expected ne $token) {
+ if ((!$isFormat and $expected and $expected ne $token) or ($isFormat and $expected eq ")" and $token ne ",")) {
emitError($file, $., "found $token but expected $expected");
$expected = "";
}
- if (($token =~ /(WEB_)?UI_(CF)?STRING(_KEY)?(_INTERNAL)?$/) || ($token =~ /WEB_UI_NSSTRING$/) || ($token =~ /WEB_UI_STRING_WITH_MNEMONIC$/)) {
+ if (($token =~ /(WEB_)?UI_(FORMAT_)?(CF)?STRING(_KEY)?(_INTERNAL)?$/) || ($token =~ /WEB_UI_NSSTRING$/) || ($token =~ /WEB_UI_STRING_WITH_MNEMONIC$/)) {
$expected = "(";
$macro = $token;
$UIString = undef;
@@ -253,6 +258,7 @@
$comment = undef;
$mnemonic = undef;
$macroLine = $.;
+ $isFormat = isFormatMacro($token);
} elsif ($token eq "(" or $token eq "[") {
++$nestingLevel if defined $nestingLevel;
$expected = "a quoted string" if $expected;
Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (286155 => 286156)
--- trunk/Source/WebCore/platform/LocalizedStrings.cpp 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2021 Apple Inc. All rights reserved.
* Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,9 @@
#include <wtf/unicode/CharacterNames.h>
#if USE(CF)
+#if PLATFORM(WIN)
+#include "WebCoreBundleWin.h"
+#endif
#include <wtf/RetainPtr.h>
#endif
@@ -43,24 +46,38 @@
namespace WebCore {
-// Because |format| is used as the second parameter to va_start, it cannot be a reference
-// type according to section 18.7/3 of the C++ N1905 standard.
-String formatLocalizedString(String format, ...)
+#if USE(CF) && !PLATFORM(WIN)
+String formatLocalizedString(CFStringRef format, ...)
{
-#if USE(CF)
va_list arguments;
va_start(arguments, format);
- ALLOW_NONLITERAL_FORMAT_BEGIN
- auto result = adoptCF(CFStringCreateWithFormatAndArguments(0, 0, format.createCFString().get(), arguments));
- ALLOW_NONLITERAL_FORMAT_END
+ auto localizedFormat = copyLocalizedString(format);
+ALLOW_NONLITERAL_FORMAT_BEGIN
+ // The 'format' parameter is already checked for correct placeholders and parameters.
+ auto result = adoptCF(CFStringCreateWithFormatAndArguments(0, 0, localizedFormat.get(), arguments));
+ALLOW_NONLITERAL_FORMAT_END
va_end(arguments);
return result.get();
+}
+#else
+// Because |format| is used as the second parameter to va_start, it cannot be a reference
+// type according to section 18.7/3 of the C++ N1905 standard.
+String formatLocalizedString(const char* format, ...)
+{
+#if USE(CF) && PLATFORM(WIN)
+ auto cfFormat = adoptCF(CFStringCreateWithCStringNoCopy(nullptr, format, kCFStringEncodingUTF8, kCFAllocatorNull));
+ va_list arguments;
+ va_start(arguments, format);
+ auto localizedFormat = copyLocalizedString(cfFormat.get());
+ auto result = adoptCF(CFStringCreateWithFormatAndArguments(0, 0, localizedFormat.get(), arguments));
+ va_end(arguments);
+ return result.get();
#elif USE(GLIB)
va_list arguments;
va_start(arguments, format);
- GUniquePtr<gchar> result(g_strdup_vprintf(format.utf8().data(), arguments));
+ GUniquePtr<gchar> result(g_strdup_vprintf(format, arguments));
va_end(arguments);
return String::fromUTF8(result.get());
#else
@@ -68,14 +85,62 @@
return format;
#endif
}
+#endif
-#if !USE(CF)
+#if USE(CF)
+#if !PLATFORM(WIN)
+static CFBundleRef webCoreBundle()
+{
+ static NeverDestroyed<RetainPtr<CFBundleRef>> bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebCore"));
+ ASSERT(bundle.get());
+ return bundle.get().get();
+}
+#endif
+RetainPtr<CFStringRef> copyLocalizedString(CFStringRef key)
+{
+#if !PLATFORM(IOS_FAMILY)
+ // Can be called on a dispatch queue when initializing strings on iOS.
+ // See LoadWebLocalizedStrings and <rdar://problem/7902473>.
+ ASSERT(isMainThread());
+#endif
+
+ static CFStringRef notFound = CFSTR("localized string not found");
+
+#if PLATFORM(WIN)
+ CFBundleRef bundle = webKitBundle();
+#else
+ CFBundleRef bundle = webCoreBundle();
+#endif
+ auto result = adoptCF(CFBundleCopyLocalizedString(bundle, key, notFound, nullptr));
+
+#if ASSERT_ENABLED
+ if (result.get() == notFound) {
+ char keyCString[256];
+ CFStringGetCString(key, keyCString, sizeof(keyCString), kCFStringEncodingUTF8);
+ ASSERT_WITH_MESSAGE(result.get() != notFound, "Could not find localizable string '%s' in bundle", keyCString);
+ }
+#endif
+
+ return result;
+}
+#endif
+
+#if USE(CF) && !PLATFORM(WIN)
+String localizedString(CFStringRef key)
+{
+ return copyLocalizedString(key).get();
+}
+#else
String localizedString(const char* key)
{
+#if USE(CF)
+ auto keyString = adoptCF(CFStringCreateWithCStringNoCopy(nullptr, key, kCFStringEncodingUTF8, kCFAllocatorNull));
+ return copyLocalizedString(keyString.get()).get();
+#else
return String::fromUTF8(key, strlen(key));
+#endif
}
-
#endif
#if ENABLE(CONTEXT_MENUS)
@@ -233,9 +298,9 @@
{
#if USE(CF)
auto selectedCFString = truncatedStringForMenuItem(selectedString).createCFString();
- return formatLocalizedString(WEB_UI_CFSTRING("Look Up “%@”", "Look Up context menu item with selected word"), selectedCFString.get());
+ return WEB_UI_FORMAT_CFSTRING("Look Up “%@”", "Look Up context menu item with selected word", selectedCFString.get());
#elif USE(GLIB)
- return formatLocalizedString(WEB_UI_STRING("Look Up “%s”", "Look Up context menu item with selected word"), truncatedStringForMenuItem(selectedString).utf8().data());
+ return WEB_UI_FORMAT_STRING("Look Up “%s”", "Look Up context menu item with selected word", truncatedStringForMenuItem(selectedString).utf8().data());
#else
return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForMenuItem(selectedString));
#endif
@@ -246,7 +311,7 @@
String contextMenuItemTagTranslate(const String& selectedString)
{
auto selectedCFString = truncatedStringForMenuItem(selectedString).createCFString();
- return formatLocalizedString(WEB_UI_CFSTRING("Translate “%@”", "Translate context menu item with selected word"), selectedCFString.get());
+ return WEB_UI_FORMAT_CFSTRING("Translate “%@”", "Translate context menu item with selected word", selectedCFString.get());
}
#endif
@@ -824,7 +889,7 @@
String multipleFileUploadText(unsigned numberOfFiles)
{
- return formatLocalizedString(WEB_UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles);
+ return WEB_UI_FORMAT_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files", numberOfFiles);
}
String unknownFileSizeText()
@@ -846,11 +911,11 @@
auto height = adoptCF(CFNumberCreate(0, kCFNumberIntType, &heightInt));
auto heightString = adoptCF(CFNumberFormatterCreateStringWithNumber(0, formatter.get(), height.get()));
- return formatLocalizedString(WEB_UI_CFSTRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename.createCFString().get(), widthString.get(), heightString.get());
+ return WEB_UI_FORMAT_CFSTRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)", filename.createCFString().get(), widthString.get(), heightString.get());
#elif USE(GLIB)
- return formatLocalizedString(WEB_UI_STRING("%s %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename.utf8().data(), size.width(), size.height());
+ return WEB_UI_FORMAT_STRING("%s %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)", filename.utf8().data(), size.width(), size.height());
#else
- return formatLocalizedString(WEB_UI_STRING("<filename> %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()).replace("<filename>", filename);
+ return WEB_UI_FORMAT_STRING("<filename> %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)", size.width(), size.height()).replace("<filename>", filename);
#endif
}
@@ -972,12 +1037,12 @@
seconds %= 60;
if (days)
- return formatLocalizedString(WEB_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);
+ return WEB_UI_FORMAT_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);
if (hours)
- return formatLocalizedString(WEB_UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds);
+ return WEB_UI_FORMAT_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes", hours, minutes, seconds);
if (minutes)
- return formatLocalizedString(WEB_UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds);
- return formatLocalizedString(WEB_UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds);
+ return WEB_UI_FORMAT_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds", minutes, seconds);
+ return WEB_UI_FORMAT_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds", seconds);
}
String validationMessageValueMissingText()
@@ -1038,13 +1103,13 @@
#if !PLATFORM(GTK)
String validationMessageTooShortText(int, int minLength)
{
- return formatLocalizedString(WEB_UI_STRING("Use at least %d characters", "Validation message for form control elements with a value shorter than minimum allowed length"), minLength);
+ return WEB_UI_FORMAT_STRING("Use at least %d characters", "Validation message for form control elements with a value shorter than minimum allowed length", minLength);
}
#if !PLATFORM(COCOA)
String validationMessageTooLongText(int, int maxLength)
{
- return formatLocalizedString(WEB_UI_STRING("Use no more than %d characters", "Validation message for form control elements with a value shorter than maximum allowed length"), maxLength);
+ return WEB_UI_FORMAT_STRING("Use no more than %d characters", "Validation message for form control elements with a value shorter than maximum allowed length", maxLength);
}
#endif
#endif
@@ -1052,9 +1117,9 @@
String validationMessageRangeUnderflowText(const String& minimum)
{
#if USE(CF)
- return formatLocalizedString(WEB_UI_CFSTRING("Value must be greater than or equal to %@", "Validation message for input form controls with value lower than allowed minimum"), minimum.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING("Value must be greater than or equal to %@", "Validation message for input form controls with value lower than allowed minimum", minimum.createCFString().get());
#elif USE(GLIB)
- return formatLocalizedString(WEB_UI_STRING("Value must be greater than or equal to %s", "Validation message for input form controls with value lower than allowed minimum"), minimum.utf8().data());
+ return WEB_UI_FORMAT_STRING("Value must be greater than or equal to %s", "Validation message for input form controls with value lower than allowed minimum", minimum.utf8().data());
#else
UNUSED_PARAM(minimum);
return WEB_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum");
@@ -1064,9 +1129,9 @@
String validationMessageRangeOverflowText(const String& maximum)
{
#if USE(CF)
- return formatLocalizedString(WEB_UI_CFSTRING("Value must be less than or equal to %@", "Validation message for input form controls with value higher than allowed maximum"), maximum.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING("Value must be less than or equal to %@", "Validation message for input form controls with value higher than allowed maximum", maximum.createCFString().get());
#elif USE(GLIB)
- return formatLocalizedString(WEB_UI_STRING("Value must be less than or equal to %s", "Validation message for input form controls with value higher than allowed maximum"), maximum.utf8().data());
+ return WEB_UI_FORMAT_STRING("Value must be less than or equal to %s", "Validation message for input form controls with value higher than allowed maximum", maximum.utf8().data());
#else
UNUSED_PARAM(maximum);
return WEB_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum");
@@ -1109,7 +1174,7 @@
String addTrackLabelAsSuffix(const String& text, const String& label)
{
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ (%@)", "%@ (%@) (audio/text track)", "Audio/Text track display name format that includes the label and language of the track, in the form of 'Language (Label)'."), text.createCFString().get(), label.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ (%@)", "%@ (%@) (audio/text track)", "Audio/Text track display name format that includes the label and language of the track, in the form of 'Language (Label)'.", text.createCFString().get(), label.createCFString().get());
}
String textTrackKindClosedCaptionsDisplayName()
@@ -1121,7 +1186,7 @@
{
if (text.isEmpty())
return textTrackKindClosedCaptionsDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ CC", "%@ CC (text track)", "Closed captions text track display name format that includes the language and/or locale (e.g. 'English CC')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ CC", "%@ CC (text track)", "Closed captions text track display name format that includes the language and/or locale (e.g. 'English CC').", text.createCFString().get());
}
String textTrackKindCaptionsDisplayName()
@@ -1133,7 +1198,7 @@
{
if (text.isEmpty())
return textTrackKindCaptionsDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Captions", "%@ Captions (text track)", "Captions text track display name format that includes the language and/or locale (e.g. 'English Captions')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Captions", "%@ Captions (text track)", "Captions text track display name format that includes the language and/or locale (e.g. 'English Captions').", text.createCFString().get());
}
String textTrackKindDescriptionsDisplayName()
@@ -1145,7 +1210,7 @@
{
if (text.isEmpty())
return textTrackKindDescriptionsDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Descriptions", "%@ Descriptions (text track)", "Descriptions text track display name format that includes the language and/or locale (e.g. 'English Descriptions')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Descriptions", "%@ Descriptions (text track)", "Descriptions text track display name format that includes the language and/or locale (e.g. 'English Descriptions').", text.createCFString().get());
}
String textTrackKindChaptersDisplayName()
@@ -1157,7 +1222,7 @@
{
if (text.isEmpty())
return textTrackKindChaptersDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Chapters", "%@ Chapters (text track)", "Chapters text track display name format that includes the language and/or locale (e.g. 'English Chapters')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Chapters", "%@ Chapters (text track)", "Chapters text track display name format that includes the language and/or locale (e.g. 'English Chapters').", text.createCFString().get());
}
String textTrackKindMetadataDisplayName()
@@ -1169,7 +1234,7 @@
{
if (text.isEmpty())
return textTrackKindMetadataDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Metadata", "%@ Metadata (text track)", "Metadata text track display name format that includes the language and/or locale (e.g. 'English Metadata')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Metadata", "%@ Metadata (text track)", "Metadata text track display name format that includes the language and/or locale (e.g. 'English Metadata').", text.createCFString().get());
}
String textTrackKindSDHDisplayName()
@@ -1181,7 +1246,7 @@
{
if (text.isEmpty())
return textTrackKindSDHDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ SDH", "%@ SDH (text track)", "SDH (i.e. deaf and/or hard of hearing) text track display name format that includes the language and/or locale (e.g. 'English SDH')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ SDH", "%@ SDH (text track)", "SDH (i.e. deaf and/or hard of hearing) text track display name format that includes the language and/or locale (e.g. 'English SDH').", text.createCFString().get());
}
String textTrackKindEasyReaderDisplayName()
@@ -1193,7 +1258,7 @@
{
if (text.isEmpty())
return textTrackKindEasyReaderDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Easy Reader", "%@ Easy Reader (text track)", "Easy Reader (i.e. 3rd-grade level) text track display name format that includes the language and/or locale (e.g. 'English Easy Reader')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Easy Reader", "%@ Easy Reader (text track)", "Easy Reader (i.e. 3rd-grade level) text track display name format that includes the language and/or locale (e.g. 'English Easy Reader').", text.createCFString().get());
}
String textTrackKindForcedDisplayName()
@@ -1205,7 +1270,7 @@
{
if (text.isEmpty())
return textTrackKindForcedDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Forced", "%@ Forced (text track)", "Forced text track display name format that includes the language and/or locale (e.g. 'English Forced')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Forced", "%@ Forced (text track)", "Forced text track display name format that includes the language and/or locale (e.g. 'English Forced').", text.createCFString().get());
}
String audioTrackKindDescriptionsDisplayName()
@@ -1217,7 +1282,7 @@
{
if (text.isEmpty())
return audioTrackKindDescriptionsDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Descriptions", "%@ Descriptions (audio track)", "Descriptions audio track display name format that includes the language and/or locale (e.g. 'English Descriptions')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Descriptions", "%@ Descriptions (audio track)", "Descriptions audio track display name format that includes the language and/or locale (e.g. 'English Descriptions').", text.createCFString().get());
}
String audioTrackKindCommentaryDisplayName()
@@ -1229,7 +1294,7 @@
{
if (text.isEmpty())
return audioTrackKindCommentaryDisplayName();
- return formatLocalizedString(WEB_UI_CFSTRING_KEY("%@ Commentary", "%@ Commentary (audio track)", "Commentary audio track display name format that includes the language and/or locale (e.g. 'English Commentary')."), text.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING_KEY("%@ Commentary", "%@ Commentary (audio track)", "Commentary audio track display name format that includes the language and/or locale (e.g. 'English Commentary').", text.createCFString().get());
}
#endif // USE(CF)
@@ -1256,9 +1321,9 @@
String webCryptoMasterKeyKeychainLabel(const String& localizedApplicationName)
{
#if USE(CF)
- return formatLocalizedString(WEB_UI_CFSTRING("%@ WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain"), localizedApplicationName.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING("%@ WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain", localizedApplicationName.createCFString().get());
#elif USE(GLIB)
- return formatLocalizedString(WEB_UI_STRING("%s WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain"), localizedApplicationName.utf8().data());
+ return WEB_UI_FORMAT_STRING("%s WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain", localizedApplicationName.utf8().data());
#else
return WEB_UI_STRING("<application> WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain").replace("<application>", localizedApplicationName);
#endif
@@ -1332,12 +1397,12 @@
// information is provided to help users to make decisions.
String makeCredentialTouchIDPromptTitle(const String& bundleName, const String& domain)
{
- return formatLocalizedString(WEB_UI_CFSTRING("“%@” would like to use Touch ID for “%@”.", "Allow the specified bundle to use Touch ID to sign in to the specified website on this device"), bundleName.createCFString().get(), domain.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING("“%@” would like to use Touch ID for “%@”.", "Allow the specified bundle to use Touch ID to sign in to the specified website on this device", bundleName.createCFString().get(), domain.createCFString().get());
}
String getAssertionTouchIDPromptTitle(const String& bundleName, const String& domain)
{
- return formatLocalizedString(WEB_UI_CFSTRING("“%@” would like to sign in to “%@”.", "Allow the specified bundle to sign in to the specified website"), bundleName.createCFString().get(), domain.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING("“%@” would like to sign in to “%@”.", "Allow the specified bundle to sign in to the specified website", bundleName.createCFString().get(), domain.createCFString().get());
}
String genericTouchIDPromptTitle()
Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (286155 => 286156)
--- trunk/Source/WebCore/platform/LocalizedStrings.h 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2021 Apple Inc. All rights reserved.
* Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,10 @@
#include <wtf/Forward.h>
+#ifdef __OBJC__
+#include <wtf/cocoa/TypeCastsCocoa.h>
+#endif
+
#if USE(GLIB) && defined(GETTEXT_PACKAGE)
#include <glib/gi18n-lib.h>
#endif
@@ -377,11 +381,16 @@
String contextMenuItemTagTranslate(const String& selectedString);
#endif
-#if USE(GLIB) && defined(GETTEXT_PACKAGE)
+#if USE(CF) && !PLATFORM(WIN)
+#define WEB_UI_STRING(string, description) WebCore::localizedString(CFSTR(string))
+#define WEB_UI_STRING_KEY(string, key, description) WebCore::localizedString(CFSTR(key))
+#define WEB_UI_STRING_WITH_MNEMONIC(string, mnemonic, description) WebCore::localizedString(CFSTR(string))
+#elif USE(GLIB) && defined(GETTEXT_PACKAGE)
#define WEB_UI_STRING(string, description) WebCore::localizedString(_(string))
#define WEB_UI_STRING_KEY(string, key, description) WebCore::localizedString(C_(key, string))
#define WEB_UI_STRING_WITH_MNEMONIC(string, mnemonic, description) WebCore::localizedString(_(mnemonic))
#else
+// Work around default Mac Roman encoding of CFSTR() for Apple Windows port.
#define WEB_UI_STRING(string, description) WebCore::localizedString(string)
#define WEB_UI_STRING_KEY(string, key, description) WebCore::localizedString(key)
#define WEB_UI_STRING_WITH_MNEMONIC(string, mnemonic, description) WebCore::localizedString(string)
@@ -389,16 +398,53 @@
#if USE(CF)
// This is exactly as WEB_UI_STRING, but renamed to ensure the string is not scanned by non-CF ports.
+#if PLATFORM(WIN)
+// Work around default Mac Roman encoding of CFSTR() for Apple Windows port.
#define WEB_UI_CFSTRING(string, description) WebCore::localizedString(string)
#define WEB_UI_CFSTRING_KEY(string, key, description) WebCore::localizedString(key)
+#else
+#define WEB_UI_CFSTRING(string, description) WebCore::localizedString(CFSTR(string))
+#define WEB_UI_CFSTRING_KEY(string, key, description) WebCore::localizedString(CFSTR(key))
#endif
+ WEBCORE_EXPORT RetainPtr<CFStringRef> copyLocalizedString(CFStringRef key);
+#endif
+
+#if USE(CF) && !PLATFORM(WIN)
+ WEBCORE_EXPORT String localizedString(CFStringRef key);
+#else
WEBCORE_EXPORT String localizedString(const char* key);
- String formatLocalizedString(String format, ...);
+#endif
+#if USE(CF)
+#if PLATFORM(WIN)
+// Work around default Mac Roman encoding of CFSTR() for Apple Windows port.
+#define WEB_UI_FORMAT_CFSTRING(string, description, ...) WebCore::formatLocalizedString(string, __VA_ARGS__)
+#define WEB_UI_FORMAT_CFSTRING_KEY(string, key, description, ...) WebCore::formatLocalizedString(key, __VA_ARGS__)
+#define WEB_UI_FORMAT_STRING(string, description, ...) WebCore::formatLocalizedString(string, __VA_ARGS__)
+#else
+#define WEB_UI_FORMAT_CFSTRING(string, description, ...) WebCore::formatLocalizedString(CFSTR(string), __VA_ARGS__)
+#define WEB_UI_FORMAT_CFSTRING_KEY(string, key, description, ...) WebCore::formatLocalizedString(CFSTR(key), __VA_ARGS__)
+#define WEB_UI_FORMAT_STRING(string, description, ...) WebCore::formatLocalizedString(CFSTR(string), __VA_ARGS__)
+#endif // PLATFORM(WIN)
+#elif USE(GLIB) && defined(GETTEXT_PACKAGE)
+#define WEB_UI_FORMAT_STRING(string, description, ...) WebCore::formatLocalizedString(_(string), __VA_ARGS__)
+#else
+#define WEB_UI_FORMAT_STRING(string, description, ...) WebCore::formatLocalizedString(string, __VA_ARGS__)
+#endif
+
+#if USE(CF) && !PLATFORM(WIN)
+ String formatLocalizedString(CFStringRef format, ...) CF_FORMAT_FUNCTION(1, 2);
+#else
+ String formatLocalizedString(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
+#endif
+
#ifdef __OBJC__
#define WEB_UI_NSSTRING(string, description) WebCore::localizedNSString(string)
- WEBCORE_EXPORT NSString *localizedNSString(NSString *key) NS_FORMAT_ARGUMENT(1);
+ inline NS_FORMAT_ARGUMENT(1) NSString *localizedNSString(NSString *key)
+ {
+ return bridge_cast(copyLocalizedString(bridge_cast(key)).autorelease());
+ }
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm (286155 => 286156)
--- trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,24 +35,6 @@
namespace WebCore {
-NSString *localizedNSString(NSString *key)
-{
-#if !PLATFORM(IOS_FAMILY)
- // Can be called on a dispatch queue when initializing strings on iOS.
- // See LoadWebLocalizedStrings and <rdar://problem/7902473>.
- ASSERT(isMainThread());
-#endif
-
- static NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
- return [bundle localizedStringForKey:key value:@"localized string not found" table:nullptr];
-}
-
-String localizedString(const char* key)
-{
- RetainPtr<CFStringRef> keyString = adoptCF(CFStringCreateWithCStringNoCopy(0, key, kCFStringEncodingUTF8, kCFAllocatorNull));
- return localizedNSString((__bridge NSString *)keyString.get());
-}
-
String copyImageUnknownFileLabel()
{
return WEB_UI_STRING("unknown", "Unknown filename");
@@ -79,7 +61,7 @@
String contextMenuItemTagSearchWeb()
{
auto searchProviderName = PAL::defaultSearchProviderDisplayName();
- return formatLocalizedString(WEB_UI_STRING("Search with %@", "Search with search provider context menu item with provider name inserted"), searchProviderName.get());
+ return WEB_UI_FORMAT_CFSTRING("Search with %@", "Search with search provider context menu item with provider name inserted", searchProviderName.get());
}
String contextMenuItemTagShowFonts()
@@ -233,7 +215,7 @@
String keygenKeychainItemName(const String& host)
{
- return formatLocalizedString(WEB_UI_STRING("Key from %@", "Name of keychain key generated by the KEYGEN tag"), host.createCFString().get());
+ return WEB_UI_FORMAT_CFSTRING("Key from %@", "Name of keychain key generated by the KEYGEN tag", host.createCFString().get());
}
#if PLATFORM(IOS_FAMILY)
@@ -245,7 +227,7 @@
case 1:
return WEB_UI_STRING("1 Item", "Present the element <select multiple> when a single <option> is selected (iOS only)");
default:
- return formatLocalizedString(WEB_UI_STRING("%zu Items", "Present the number of selected <option> items in a <select multiple> element (iOS only)"), count);
+ return WEB_UI_FORMAT_CFSTRING("%zu Items", "Present the number of selected <option> items in a <select multiple> element (iOS only)", count);
}
}
@@ -278,7 +260,7 @@
String validationMessageTooLongText(int, int maxLength)
{
- return [NSString localizedStringWithFormat:WEB_UI_NSSTRING(@"Use no more than %d character(s)", @"Validation message for form control elements with a value shorter than maximum allowed length"), maxLength];
+ return WEB_UI_FORMAT_CFSTRING("Use no more than %d character(s)", "Validation message for form control elements with a value shorter than maximum allowed length", maxLength);
}
#if PLATFORM(MAC)
Modified: trunk/Source/WebCore/platform/gtk/po/CMakeLists.txt (286155 => 286156)
--- trunk/Source/WebCore/platform/gtk/po/CMakeLists.txt 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/platform/gtk/po/CMakeLists.txt 2021-11-25 01:39:10 UTC (rev 286156)
@@ -25,6 +25,7 @@
--package-name="webkitgtk"
--keyword=_
--keyword=N_
+ --keyword=WEB_UI_FORMAT_STRING:1
--keyword=WEB_UI_STRING:1
--keyword=WEB_UI_STRING_KEY:3c,1
--keyword=WEB_UI_STRING_WITH_MNEMONIC:2
Modified: trunk/Source/WebCore/platform/gtk/po/ChangeLog (286155 => 286156)
--- trunk/Source/WebCore/platform/gtk/po/ChangeLog 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/platform/gtk/po/ChangeLog 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,3 +1,16 @@
+2021-11-24 David Kilzer <[email protected]>
+
+ Compiler should be able to check localized format strings for consistency
+ <https://webkit.org/b/232686>
+ <rdar://problem/84994345>
+
+ Reviewed by Darin Adler.
+
+ * CMakeLists.txt:
+ (add_custom_command: xgettext):
+ - Add WEB_UI_FORMAT_STRING to list of macros containing
+ localizable strings.
+
2021-09-13 Piotr Drąg <[email protected]>
[GTK][l10n] Updated Polish translation of WebKitGTK for 2.34
Modified: trunk/Source/WebCore/platform/win/LocalizedStringsWin.cpp (286155 => 286156)
--- trunk/Source/WebCore/platform/win/LocalizedStringsWin.cpp 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebCore/platform/win/LocalizedStringsWin.cpp 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,36 +27,10 @@
#include "LocalizedStrings.h"
#include "NotImplemented.h"
-#include "WebCoreInstanceHandle.h"
-#include <windows.h>
-#include <wtf/Assertions.h>
-#include <wtf/MainThread.h>
-#include <wtf/StdLibExtras.h>
#include <wtf/text/WTFString.h>
-#if USE(CF)
-#include "WebCoreBundleWin.h"
-#include <CoreFoundation/CFBundle.h>
-#include <wtf/RetainPtr.h>
-#endif
-
namespace WebCore {
-#if USE(CF)
-String localizedString(const char* key)
-{
- ASSERT(isMainThread());
-
- static CFStringRef notFound = CFSTR("localized string not found");
-
- RetainPtr<CFStringRef> keyString = adoptCF(CFStringCreateWithCStringNoCopy(NULL, key, kCFStringEncodingUTF8, kCFAllocatorNull));
- RetainPtr<CFStringRef> result = adoptCF(CFCopyLocalizedStringWithDefaultValue(keyString.get(), 0, webKitBundle(), notFound, 0));
- ASSERT_WITH_MESSAGE(result.get() != notFound, "could not find localizable string %s in bundle", key);
-
- return result.get();
-}
-#endif
-
String uploadFileText()
{
notImplemented();
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (286155 => 286156)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,3 +1,17 @@
+2021-11-24 David Kilzer <[email protected]>
+
+ Compiler should be able to check localized format strings for consistency
+ <https://webkit.org/b/232686>
+ <rdar://problem/84994345>
+
+ Reviewed by Darin Adler.
+
+ * Misc/WebLocalizableStringsInternal.mm:
+ (WebLocalizedStringInternal):
+ - Use localizedNSString() instead of localizedString() to
+ eliminate the need to convert from
+ CFString -> String -> NSString.
+
2021-11-16 Nikolaos Mouchtaris <[email protected]>
Rename TextDecoration to TextDecorationLine
Modified: trunk/Source/WebKitLegacy/mac/Misc/WebLocalizableStringsInternal.mm (286155 => 286156)
--- trunk/Source/WebKitLegacy/mac/Misc/WebLocalizableStringsInternal.mm 2021-11-25 00:32:30 UTC (rev 286155)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebLocalizableStringsInternal.mm 2021-11-25 01:39:10 UTC (rev 286156)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,11 +26,11 @@
#import "WebLocalizableStringsInternal.h"
#import <WebCore/LocalizedStrings.h>
-#import <wtf/text/WTFString.h>
using namespace WebCore;
NSString *WebLocalizedStringInternal(const char* key)
{
- return localizedString(key);
+ auto keyString = adoptCF(CFStringCreateWithCStringNoCopy(0, key, kCFStringEncodingUTF8, kCFAllocatorNull));
+ return localizedNSString(bridge_cast(keyString.get()));
}
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
