WebKit Bugzilla
Attachment 357786 Details for
Bug 153962
: Web Inspector: UIString should take an optional key and description to aid localization
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-153962-20181219232708.patch (text/plain), 7.48 KB, created by
Devin Rousso
on 2018-12-19 22:27:09 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2018-12-19 22:27:09 PST
Size:
7.48 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index aaae3ba90257556b144ebd18ee0ea02ff2b62dbf..f02967f394d6c4337c930e15425e736e2b95d208 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,20 @@ >+2018-12-19 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: WebInspector.UIString should take an optional key and description to aid localization >+ https://bugs.webkit.org/show_bug.cgi?id=153962 >+ <rdar://problem/24542505> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UserInterface/Base/LoadLocalizedStrings.js: >+ (WI.UIString): >+ >+ * UserInterface/Test/Test.js: >+ (WI.UIString): >+ >+ * UserInterface/Views/AuditTestGroupContentView.js: >+ (WI.AuditTestGroupContentView.prototype.initialLayout): >+ > 2018-12-19 Devin Rousso <drousso@apple.com> > > Web Inspector: Uncaught Exception: TypeError: null is not an object (evaluating 'effectiveDOMNode.enabledPseudoClasses') >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index bd979720f419c1ac0ef0d014c5124ae66d7fea5c..040cb01f3084e9790b27709d2963a6cc8d5a836c 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -56,7 +56,6 @@ localizedStrings["%s cannot be modified"] = "%s cannot be modified"; > localizedStrings["%s delay"] = "%s delay"; > localizedStrings["%s eval\n%s async"] = "%s eval\n%s async"; > localizedStrings["%s interval"] = "%s interval"; >-localizedStrings["%s%%"] = "%s%%"; > localizedStrings["(Action %s)"] = "(Action %s)"; > localizedStrings["(Disk)"] = "(Disk)"; > localizedStrings["(Index)"] = "(Index)"; >@@ -1039,6 +1038,8 @@ localizedStrings["\u0022%s\u0022 must be an %s"] = "\u0022%s\u0022 must be an %s > localizedStrings["\u0022%s\u0022 threw an error."] = "\u0022%s\u0022 threw an error."; > localizedStrings["\u201C%s\u201D Event Fired"] = "\u201C%s\u201D Event Fired"; > localizedStrings["\u201C%s\u201D Profile Recorded"] = "\u201C%s\u201D Profile Recorded"; >+/* The number of tests that passed expressed as a percentage, followed by a literal %. */ >+localizedStrings["audit-percentage-pass"] = "%s%%"; > localizedStrings["computed"] = "computed"; > localizedStrings["default"] = "default"; > localizedStrings["for changes to take effect"] = "for changes to take effect"; >diff --git a/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js b/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js >index f0fd8cd6ea0acf6ec516a7a6d765d31f75b411b2..c0f5a375e33dd076ac70aa8901497dddeef4577f 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js >+++ b/Source/WebInspectorUI/UserInterface/Base/LoadLocalizedStrings.js >@@ -41,23 +41,25 @@ WI.unlocalizedString = function(string) > return string; > }; > >-WI.UIString = function(string) >+WI.UIString = function(string, key, comment) > { > if (WI.dontLocalizeUserInterface) > return string; > >- if (window.localizedStrings && string in window.localizedStrings) >- return window.localizedStrings[string]; >+ key = key || string; >+ >+ if (window.localizedStrings && key in window.localizedStrings) >+ return window.localizedStrings[key]; > > if (!window.localizedStrings) >- console.error(`Attempted to load localized string "${string}" before localizedStrings was initialized.`); >+ console.error(`Attempted to load localized string "${key}" before localizedStrings was initialized.`, comment); > > if (!this._missingLocalizedStrings) > this._missingLocalizedStrings = {}; > >- if (!(string in this._missingLocalizedStrings)) { >- console.error("Localized string \"" + string + "\" was not found."); >- this._missingLocalizedStrings[string] = true; >+ if (!(key in this._missingLocalizedStrings)) { >+ console.error(`Localized string "${key}" was not found.`, comment); >+ this._missingLocalizedStrings[key] = true; > } > > return "LOCALIZED STRING NOT FOUND"; >diff --git a/Source/WebInspectorUI/UserInterface/Test/Test.js b/Source/WebInspectorUI/UserInterface/Test/Test.js >index 7f6c726ffd32ec286f12709d64c57dec9aa61d3d..f8adde814a31199222b807081ba3dacaeb27b5de 100644 >--- a/Source/WebInspectorUI/UserInterface/Test/Test.js >+++ b/Source/WebInspectorUI/UserInterface/Test/Test.js >@@ -165,7 +165,7 @@ WI.assumingMainTarget = () => WI.mainTarget; > WI.isDebugUIEnabled = () => false; > > WI.unlocalizedString = (string) => string; >-WI.UIString = (string) => string; >+WI.UIString = (string, key, comment) => string; > > WI.indentString = () => " "; > >diff --git a/Source/WebInspectorUI/UserInterface/Views/AuditTestGroupContentView.js b/Source/WebInspectorUI/UserInterface/Views/AuditTestGroupContentView.js >index 44101dad5aca3ff4540467a434686b5ebbdae81c..a9114072ae835720ecfc067e3b778294c7be3d39 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/AuditTestGroupContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/AuditTestGroupContentView.js >@@ -65,7 +65,8 @@ WI.AuditTestGroupContentView = class AuditTestGroupContentView extends WI.AuditT > > this._percentageTextElement = document.createElement("span"); > >- String.format(WI.UIString("%s%%"), [this._percentageTextElement], String.standardFormatters, this._percentageContainer, (a, b) => { >+ const format = WI.UIString("%s%%", "audit-percentage-pass", "The number of tests that passed expressed as a percentage, followed by a literal %."); >+ String.format(format, [this._percentageTextElement], String.standardFormatters, this._percentageContainer, (a, b) => { > a.append(b); > return a; > }); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index d069393c3432179af7494fd45c965f0e1e9adffe..f1af3c3d72455d947ee7fcf99c95fb5aaf71a04b 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,13 @@ >+2018-12-19 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: WebInspector.UIString should take an optional key and description to aid localization >+ https://bugs.webkit.org/show_bug.cgi?id=153962 >+ <rdar://problem/24542505> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/extract-localizable-js-strings: >+ > 2018-12-19 Chris Dumez <cdumez@apple.com> > > wtf/Optional.h: move-constructor and move-assignment operator should disengage the value being moved from >diff --git a/Tools/Scripts/extract-localizable-js-strings b/Tools/Scripts/extract-localizable-js-strings >index b4200f6ef421f4bb94f9ad89f2d450fb82686984..34b5ac7793b3806eafa542348362ed1beef415ed 100755 >--- a/Tools/Scripts/extract-localizable-js-strings >+++ b/Tools/Scripts/extract-localizable-js-strings >@@ -74,7 +74,7 @@ for my $file (sort @files) { > chomp; > > # Handle WebInspector strings. Prints a warning if a non-string literal is passed to WI.UIString(). >- HandleUIString($1, $1, "", $file, $.) while s/WI\.UIString\("([^"]+)"\)//; >+ HandleUIString($1, $2 || $1, $3 || "", $file, $.) while s/WI\.UIString\("([^"]+)"(?:,\s*"([^"]+)"(?:,\s*"([^"]+)")?)?\)//; > print "$file:$.:WARNING: $&\n" while s/WI\.UIString\(.*?\)//; > > # Handle strings for other projects that also use this script. >@@ -151,6 +151,7 @@ if ($sawError) { > my $localizedStrings = "var localizedStrings = new Object;\n\n"; > > for my $key (sort keys %commentByKey) { >+ $localizedStrings .= "/* $commentByKey{$key} */\n" if length $commentByKey{$key}; > $localizedStrings .= "localizedStrings[\"$key\"] = \"$stringByKey{$key}\";\n"; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 153962
:
357764
|
357786
|
357825