Bug 215387 - REGRESSION (r265224): Web Inspector: LOCALIZED STRING NOT FOUND next to the Image checkbox in the Sources prefs panel
Summary: REGRESSION (r265224): Web Inspector: LOCALIZED STRING NOT FOUND next to the I...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Patrick Angle
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-11 12:15 PDT by Nikita Vasilyev
Modified: 2020-08-14 10:22 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.72 KB, patch)
2020-08-11 12:16 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff
Patch (10.68 KB, patch)
2020-08-11 15:38 PDT, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch (10.79 KB, patch)
2020-08-11 16:07 PDT, Patrick Angle
no flags Details | Formatted Diff | Diff
Patch (11.54 KB, patch)
2020-08-11 16:59 PDT, Patrick Angle
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2020-08-11 12:15:13 PDT
Broke in Bug 215101 - Web Inspector: "Show transparency grid" string needs to be disambiguated for localization
Comment 1 Nikita Vasilyev 2020-08-11 12:16:53 PDT
Created attachment 406401 [details]
Patch
Comment 2 Nikita Vasilyev 2020-08-11 12:18:40 PDT
I ran Tools/Scripts/update-webkit-localizable-strings to generate this patch.
Comment 3 Radar WebKit Bug Importer 2020-08-11 12:28:56 PDT
<rdar://problem/66855263>
Comment 4 Blaze Burg 2020-08-11 12:38:27 PDT
I don't understand how this fix could be correct. The original patch was supposed to create two localizable strings. Now there's only one.
Comment 5 Nikita Vasilyev 2020-08-11 12:46:40 PDT
How did you generate Localizations/en.lproj/localizedStrings.js in your patch?
Comment 6 Nikita Vasilyev 2020-08-11 12:52:52 PDT
When two parameters are passed to WI.UIString, they are "string" and "comment" (not a key!):

```
WI.UIString = function(string, key, comment)
{
    "use strict";

    if (WI.dontLocalizeUserInterface)
        return string;

    // UIString(string, comment)
    if (arguments.length === 2) {
```

It seems to me you want to specify two different keys. One way to do that would be to specify the 3rd parameter.

Brian, do you want to take this bug?
Comment 7 Blaze Burg 2020-08-11 13:23:49 PDT
(In reply to Nikita Vasilyev from comment #6)
> When two parameters are passed to WI.UIString, they are "string" and
> "comment" (not a key!):
> 
> ```
> WI.UIString = function(string, key, comment)
> {
>     "use strict";
> 
>     if (WI.dontLocalizeUserInterface)
>         return string;
> 
>     // UIString(string, comment)
>     if (arguments.length === 2) {
> ```
> 
> It seems to me you want to specify two different keys. One way to do that
> would be to specify the 3rd parameter.
> 
> Brian, do you want to take this bug?

Ugh, I hate positional parameters. I'll fix this today.
Comment 8 Patrick Angle 2020-08-11 15:38:55 PDT
Created attachment 406427 [details]
Patch
Comment 9 Nikita Vasilyev 2020-08-11 15:47:22 PDT
Comment on attachment 406427 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406427&action=review

> Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js:1153
> -localizedStrings["Show transparency grid (tooltip)"] = "Show transparency grid";
> +/* Show transparency grid */
>  localizedStrings["Show transparency grid (settings label)"] = "Show transparency grid";
> +/* Show transparency grid */
> +localizedStrings["Show transparency grid (tooltip)"] = "Show transparency grid";

We don't copy the same text as a comment. While this fixes the bug, that's not a good practice.

The comments provide localizers with some context. Check out other comments in this file to get a better idea of an appropriate comment.
Comment 10 Devin Rousso 2020-08-11 15:56:29 PDT
Comment on attachment 406427 [details]
Patch

What you have is fine (nice first bug!), butto echo @Brian Burg

(In reply to Brian Burg from comment #7)
> Ugh, I hate positional parameters. I'll fix this today.

I feel like a better long-term solution to this would be to just eliminate the `(string, comment)` variant and instead always require a `key` if a `comment` is needed (a `key` can sometimes be enough of a comment anyways, such as bug).  That way, bugs like this can be avoided :)

If you want to do that, we'd need to change:
 - `Source/Tools/Scripts/extract-localizable-js-strings` to not use the 2nd argument as the `comment` when only 2 arguments are provided
 - `WI.UIString` to not swap the `comment` and `key` when only 2 arguments are provided
 - existing callers of `WI.UIString` (this can be done quickly just by looking at `Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js`)

This logic was added in r245827, so I'd recommend looking at that to see how it used to be before :)
Comment 11 Patrick Angle 2020-08-11 16:07:44 PDT
Created attachment 406429 [details]
Patch
Comment 12 Blaze Burg 2020-08-11 16:07:53 PDT
(In reply to Devin Rousso from comment #10)
> Comment on attachment 406427 [details]
> Patch
> 
> What you have is fine (nice first bug!), butto echo @Brian Burg
> 
> (In reply to Brian Burg from comment #7)
> > Ugh, I hate positional parameters. I'll fix this today.
> 
> I feel like a better long-term solution to this would be to just eliminate
> the `(string, comment)` variant and instead always require a `key` if a
> `comment` is needed (a `key` can sometimes be enough of a comment anyways,
> such as bug).  That way, bugs like this can be avoided :)
> 
> If you want to do that, we'd need to change:
>  - `Source/Tools/Scripts/extract-localizable-js-strings` to not use the 2nd
> argument as the `comment` when only 2 arguments are provided
>  - `WI.UIString` to not swap the `comment` and `key` when only 2 arguments
> are provided
>  - existing callers of `WI.UIString` (this can be done quickly just by
> looking at
> `Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js`)
> 
> This logic was added in r245827, so I'd recommend looking at that to see how
> it used to be before :)

Agree, but let's make a separate bug. Here: https://bugs.webkit.org/show_bug.cgi?id=215400
Comment 13 Patrick Angle 2020-08-11 16:10:38 PDT
(In reply to Nikita Vasilyev from comment #9)
> Comment on attachment 406427 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406427&action=review
> 
> > Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js:1153
> > -localizedStrings["Show transparency grid (tooltip)"] = "Show transparency grid";
> > +/* Show transparency grid */
> >  localizedStrings["Show transparency grid (settings label)"] = "Show transparency grid";
> > +/* Show transparency grid */
> > +localizedStrings["Show transparency grid (tooltip)"] = "Show transparency grid";
> 
> We don't copy the same text as a comment. While this fixes the bug, that's
> not a good practice.
> 
> The comments provide localizers with some context. Check out other comments
> in this file to get a better idea of an appropriate comment.

Thanks! I've updated the comments in the latest patch to provide better context as to where the strings appear.
Comment 14 Nikita Vasilyev 2020-08-11 16:15:38 PDT
Comment on attachment 406429 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406429&action=review

> Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js:1153
> -localizedStrings["Show transparency grid (tooltip)"] = "Show transparency grid";
> +/* Settings tab checkbox label for whether the transparency grid is shown by default */
>  localizedStrings["Show transparency grid (settings label)"] = "Show transparency grid";
> +/* Tooltip for showing the checkered transparency grid under images and canvases  */
> +localizedStrings["Show transparency grid (tooltip)"] = "Show transparency grid";

It seems to me that you edited this file directly.

This is an auto-generated file. You shouldn't edit it directly. Run `Tools/Scripts/update-webkit-localizable-strings` script to update it instead.

> Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js:50
> +        this._showGridButtonNavigationItem = new WI.ActivateButtonNavigationItem("show-grid", WI.UIString("Show transparency grid", "Show transparency grid (tooltip)", "Show transparency grid"), WI.UIString("Hide transparency grid"), "Images/NavigationItemCheckers.svg", 13, 13);

The comment should be the 3rd argument here. Instead of "Show transparency grid", it should be "Tooltip for showing ...".

Same goes for every string you changed.
Comment 15 Devin Rousso 2020-08-11 16:18:16 PDT
Comment on attachment 406429 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406429&action=review

>> Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js:50
>> +        this._showGridButtonNavigationItem = new WI.ActivateButtonNavigationItem("show-grid", WI.UIString("Show transparency grid", "Show transparency grid (tooltip)", "Show transparency grid"), WI.UIString("Hide transparency grid"), "Images/NavigationItemCheckers.svg", 13, 13);
> 
> The comment should be the 3rd argument here. Instead of "Show transparency grid", it should be "Tooltip for showing ...".
> 
> Same goes for every string you changed.

along these lines, it may be worth creating a `WI.repeatedUIString.showTransparencyGridTooltip` and a `WI.repeatedUIString.showTransparencyGridSetting` to save the trouble of repeating all these strings
Comment 16 Nikita Vasilyev 2020-08-11 16:20:41 PDT
(In reply to Devin Rousso from comment #15)
> Comment on attachment 406429 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406429&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js:50
> >> +        this._showGridButtonNavigationItem = new WI.ActivateButtonNavigationItem("show-grid", WI.UIString("Show transparency grid", "Show transparency grid (tooltip)", "Show transparency grid"), WI.UIString("Hide transparency grid"), "Images/NavigationItemCheckers.svg", 13, 13);
> > 
> > The comment should be the 3rd argument here. Instead of "Show transparency grid", it should be "Tooltip for showing ...".
> > 
> > Same goes for every string you changed.
> 
> along these lines, it may be worth creating a
> `WI.repeatedUIString.showTransparencyGridTooltip` and a
> `WI.repeatedUIString.showTransparencyGridSetting` to save the trouble of
> repeating all these strings

I was going to summit almost the same comment 😅
Comment 17 Patrick Angle 2020-08-11 16:32:24 PDT
(In reply to Devin Rousso from comment #15)
> Comment on attachment 406429 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406429&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js:50
> >> +        this._showGridButtonNavigationItem = new WI.ActivateButtonNavigationItem("show-grid", WI.UIString("Show transparency grid", "Show transparency grid (tooltip)", "Show transparency grid"), WI.UIString("Hide transparency grid"), "Images/NavigationItemCheckers.svg", 13, 13);
> > 
> > The comment should be the 3rd argument here. Instead of "Show transparency grid", it should be "Tooltip for showing ...".
> > 
> > Same goes for every string you changed.
> 
> along these lines, it may be worth creating a
> `WI.repeatedUIString.showTransparencyGridTooltip` and a
> `WI.repeatedUIString.showTransparencyGridSetting` to save the trouble of
> repeating all these strings

Is there any value in creating a `WI.repeatedUIString.showTransparencyGridSetting` given it is only used once for the Settings tab? The tooltip certainly makes sense to define once.
Comment 18 Devin Rousso 2020-08-11 16:40:10 PDT
(In reply to Patrick Angle from comment #17)
> Is there any value in creating a
> `WI.repeatedUIString.showTransparencyGridSetting` given it is only used once for the Settings tab? The tooltip certainly makes sense to define once.

oh yeah if it's only used once then no I wouldn't bother :P
Comment 19 Patrick Angle 2020-08-11 16:59:12 PDT
Created attachment 406436 [details]
Patch
Comment 20 Devin Rousso 2020-08-11 17:04:08 PDT
Comment on attachment 406436 [details]
Patch

r=me, nice work!

As a general piece of feedback it's always a good idea to include additional info/context in the ChangeLog so that when looking back at this change in the future there's a concise and clear explanation of what and why.  Even something as simple as "Create repeated `WI.UIString ` helper" would be helpful :)
Comment 21 EWS 2020-08-14 10:22:45 PDT
Committed r265675: <https://trac.webkit.org/changeset/265675>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 406436 [details].