Changeset 228471 in webkit


Ignore:
Timestamp:
Feb 14, 2018 10:46:10 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[Modern Media Controls] Don't use arrays as values for localisable strings
https://bugs.webkit.org/show_bug.cgi?id=182791
<rdar://problem/36007262>

Patch by Antoine Quint <Antoine Quint> on 2018-02-14
Reviewed by Dean Jackson.

Source/WebCore:

Localization tools expect localizable strings to be specified as key-value pairs where both the key and the pair
are plain strings. For the skip buttons, we used an array value to specify a replacement string. We now perform
this task in code with a centralized SkipSeconds constant defining the skip amount.

  • English.lproj/modern-media-controls-localized-strings.js:
  • Modules/modern-media-controls/controls/icon-service.js:
  • Modules/modern-media-controls/main.js:

(UIString):

  • Modules/modern-media-controls/media/skip-back-support.js:

(SkipBackSupport.prototype.buttonWasPressed):

  • Modules/modern-media-controls/media/skip-forward-support.js:

(SkipForwardSupport.prototype.buttonWasPressed):

LayoutTests:

  • media/modern-media-controls/localized-strings/replaced-string-expected.txt:
  • media/modern-media-controls/localized-strings/replaced-string.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r228470 r228471  
     12018-02-14  Antoine Quint  <graouts@apple.com>
     2
     3        [Modern Media Controls] Don't use arrays as values for localisable strings
     4        https://bugs.webkit.org/show_bug.cgi?id=182791
     5        <rdar://problem/36007262>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * media/modern-media-controls/localized-strings/replaced-string-expected.txt:
     10        * media/modern-media-controls/localized-strings/replaced-string.html:
     11
    1122018-02-14  Ryan Haddad  <ryanhaddad@apple.com>
    213
  • trunk/LayoutTests/media/modern-media-controls/localized-strings/replaced-string-expected.txt

    r225216 r228471  
    1 Testing that we can load a replaced string using UIString.
     1Testing that we can replace strings using UIString.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    55
    6 PASS UIString('Test replaced string') is "Value 15 should be printed here"
     6PASS UIString('Test replaced string', 15) is "Value 15 should be printed here"
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/media/modern-media-controls/localized-strings/replaced-string.html

    r225216 r228471  
    44<script type="text/javascript">
    55
    6 description("Testing that we can load a replaced string using UIString.");
     6description("Testing that we can replace strings using UIString.");
    77
    8 UIStrings["##REPLACEMENT_VALUE##"] = "15";
    9 UIStrings["Test replaced string"] = ["Value %s should be printed here", "##REPLACEMENT_VALUE##"];
     8UIStrings["Test replaced string"] = "Value %s should be printed here";
    109
    11 shouldBeEqualToString("UIString('Test replaced string')", "Value 15 should be printed here");
     10shouldBeEqualToString("UIString('Test replaced string', 15)", "Value 15 should be printed here");
    1211
    1312</script>
  • trunk/Source/WebCore/ChangeLog

    r228470 r228471  
     12018-02-14  Antoine Quint  <graouts@apple.com>
     2
     3        [Modern Media Controls] Don't use arrays as values for localisable strings
     4        https://bugs.webkit.org/show_bug.cgi?id=182791
     5        <rdar://problem/36007262>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Localization tools expect localizable strings to be specified as key-value pairs where both the key and the pair
     10        are plain strings. For the skip buttons, we used an array value to specify a replacement string. We now perform
     11        this task in code with a centralized SkipSeconds constant defining the skip amount.
     12
     13        * English.lproj/modern-media-controls-localized-strings.js:
     14        * Modules/modern-media-controls/controls/icon-service.js:
     15        * Modules/modern-media-controls/main.js:
     16        (UIString):
     17        * Modules/modern-media-controls/media/skip-back-support.js:
     18        (SkipBackSupport.prototype.buttonWasPressed):
     19        * Modules/modern-media-controls/media/skip-forward-support.js:
     20        (SkipForwardSupport.prototype.buttonWasPressed):
     21
    1222018-02-14  Ryan Haddad  <ryanhaddad@apple.com>
    223
  • trunk/Source/WebCore/English.lproj/modern-media-controls-localized-strings.js

    r225216 r228471  
    11const UIStrings = {
    2     "##SKIP_AMOUNT##": "15",
    32    "AirPlay": "AirPlay",
    43    "Audio": "Audio",
     
    1918    "Remaining": "Remaining",
    2019    "Rewind": "Rewind",
    21     "Skip Back 15 seconds": ["Skip Back %s seconds", "##SKIP_AMOUNT##"],
    22     "Skip Forward 15 seconds": ["Skip Forward %s seconds", "##SKIP_AMOUNT##"],
     20    "Skip Back %s Seconds": "Skip Back %s Seconds",
     21    "Skip Forward %s Seconds": "Skip Forward %s Seconds",
    2322    "Subtitles": "Subtitles",
    2423    "This video is playing in picture in picture.": "This video is playing in picture in picture.",
  • trunk/Source/WebCore/Modules/modern-media-controls/controls/icon-service.js

    r218991 r228471  
    3636    Play            : { name: "Play", type: "svg", label: UIString("Play") },
    3737    Rewind          : { name: "Rewind", type: "svg", label: UIString("Rewind") },
    38     SkipBack        : { name: "SkipBack15", type: "svg", label: UIString("Skip Back 15 seconds") },
    39     SkipForward     : { name: "SkipForward15", type: "svg", label: UIString("Skip Forward 15 seconds") },
     38    SkipBack        : { name: "SkipBack15", type: "svg", label: UIString("Skip Back %s Seconds", SkipSeconds) },
     39    SkipForward     : { name: "SkipForward15", type: "svg", label: UIString("Skip Forward %s Seconds", SkipSeconds) },
    4040    Tracks          : { name: "MediaSelector", type: "svg", label: UIString("Media Selection") },
    4141    Volume          : { name: "VolumeHi", type: "svg", label: UIString("Mute") },
  • trunk/Source/WebCore/Modules/modern-media-controls/main.js

    r225216 r228471  
    2424 */
    2525
     26const SkipSeconds = 15;
     27
    2628let mediaControlsHost;
    2729
     
    3840}
    3941
    40 function UIString(stringToLocalize)
     42function UIString(stringToLocalize, replacementString)
    4143{
    4244    let allLocalizedStrings = {};
     
    4951        return stringToLocalize;
    5052
    51     // We allow an array of a string and a replacement.
    52     if (Array.isArray(localizedString) && localizedString.length == 2)
    53         return localizedString[0].replace("%s", UIString(localizedString[1]));
     53    if (replacementString)
     54        return localizedString.replace("%s", replacementString);
    5455
    5556    return localizedString;
  • trunk/Source/WebCore/Modules/modern-media-controls/media/skip-back-support.js

    r217823 r228471  
    2424 */
    2525
    26 const SkipBackSeconds = 15;
    27 
    2826class SkipBackSupport extends MediaControllerSupport
    2927{
     
    4442    {
    4543        const media = this.mediaController.media;
    46         media.currentTime = Math.max(media.currentTime - SkipBackSeconds, media.seekable.start(0));
     44        media.currentTime = Math.max(media.currentTime - SkipSeconds, media.seekable.start(0));
    4745    }
    4846
  • trunk/Source/WebCore/Modules/modern-media-controls/media/skip-forward-support.js

    r217823 r228471  
    2424 */
    2525
    26 const SkipForwardSeconds = 15;
    27 
    2826class SkipForwardSupport extends MediaControllerSupport
    2927{
     
    4442    {
    4543        const media = this.mediaController.media;
    46         media.currentTime = Math.min(media.currentTime + SkipForwardSeconds, media.seekable.end(0));
     44        media.currentTime = Math.min(media.currentTime + SkipSeconds, media.seekable.end(0));
    4745    }
    4846
Note: See TracChangeset for help on using the changeset viewer.