Changeset 167596 in webkit


Ignore:
Timestamp:
Apr 21, 2014 11:06:20 AM (10 years ago)
Author:
dino@apple.com
Message:

[Media] Clean up localized strings in controls
https://bugs.webkit.org/show_bug.cgi?id=131857
<rdar://problem/16663005>

Reviewed by Eric Carlson.

There is no need for separate localization files
on OS X and iOS. Move the small number of iOS-specific
localizations into a shared file.

We also don't need a function to return a static table.
Ultimately I think we want a top-level WebKit object that
hold the table, but for now use a global variable
called UIStringTable. Since we're in an isolated world, we
won't clash with anything.

I noticed a few cases were we grab a localized string and
then instantly run a replacement on it. This should be
supported directly in the UIString() accessor.

  • English.lproj/mediaControlsLocalizedStrings.js: Add iOS strings. Just

use a static table.
(mediaControlsLocalizedStrings): Deleted.

  • English.lproj/mediaControlsLocalizedStringsiOS.js: Removed.
  • Modules/mediacontrols/mediaControlsApple.js:

(Controller.prototype.extend): Fix braces.
(Controller.prototype.UIString): Use the string table, and allow replacement.
(Controller.prototype.createControls): Use new UIString replacement.

  • Modules/mediacontrols/mediaControlsiOS.js:

(ControllerIOS.prototype.updateWirelessPlaybackStatus): Use new UIString.
(ControllerIOS.prototype.UIString): Deleted. Use the parent class version.

  • WebCore.xcodeproj/project.pbxproj: Remove file from Resources.
  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::mediaControlsScript): No need to include the iOS
specific localization file.

Location:
trunk/Source/WebCore
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167595 r167596  
     12014-04-18  Dean Jackson  <dino@apple.com>
     2
     3        [Media] Clean up localized strings in controls
     4        https://bugs.webkit.org/show_bug.cgi?id=131857
     5        <rdar://problem/16663005>
     6
     7        Reviewed by Eric Carlson.
     8
     9        There is no need for separate localization files
     10        on OS X and iOS. Move the small number of iOS-specific
     11        localizations into a shared file.
     12
     13        We also don't need a function to return a static table.
     14        Ultimately I think we want a top-level WebKit object that
     15        hold the table, but for now use a global variable
     16        called UIStringTable. Since we're in an isolated world, we
     17        won't clash with anything.
     18
     19        I noticed a few cases were we grab a localized string and
     20        then instantly run a replacement on it. This should be
     21        supported directly in the UIString() accessor.
     22
     23        * English.lproj/mediaControlsLocalizedStrings.js: Add iOS strings. Just
     24        use a static table.
     25        (mediaControlsLocalizedStrings): Deleted.
     26        * English.lproj/mediaControlsLocalizedStringsiOS.js: Removed.
     27        * Modules/mediacontrols/mediaControlsApple.js:
     28        (Controller.prototype.extend): Fix braces.
     29        (Controller.prototype.UIString): Use the string table, and allow replacement.
     30        (Controller.prototype.createControls): Use new UIString replacement.
     31        * Modules/mediacontrols/mediaControlsiOS.js:
     32        (ControllerIOS.prototype.updateWirelessPlaybackStatus): Use new UIString.
     33        (ControllerIOS.prototype.UIString): Deleted. Use the parent class version.
     34        * WebCore.xcodeproj/project.pbxproj: Remove file from Resources.
     35        * rendering/RenderThemeIOS.mm:
     36        (WebCore::RenderThemeIOS::mediaControlsScript): No need to include the iOS
     37        specific localization file.
     38
    1392014-04-21  Brent Fulgham  <bfulgham@apple.com>
    240
  • trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js

    r167145 r167596  
    1 function mediaControlsLocalizedStrings() {
    2     return {
    3         'Aborted': 'Aborted',
    4         'Audio Playback': 'Audio Playback',
    5         'Captions': 'Captions',
    6         'Display Full Screen': 'Display Full Screen',
    7         'Duration': 'Duration',
    8         'Elapsed': 'Elapsed',
    9         'Error': 'Error',
    10         'Exit Full Screen': 'Exit Full Screen',
    11         'Fast Forward': 'Fast Forward',
    12         'Loading': 'Loading',
    13         'Maximum Volume': 'Maximum Volume',
    14         'Minimum Volume': 'Minimum Volume',
    15         'Mute': 'Mute',
    16         'Pause': 'Pause',
    17         'Play': 'Play',
    18         'Remaining': 'Remaining',
    19         'Rewind': 'Rewind',
    20         'Rewind %%sec%% Seconds': 'Rewind %%sec%% Seconds',
    21         'Stalled': 'Stalled',
    22         'Subtitles': 'Subtitles',
    23         'Suspended': 'Suspended',
    24         'Unmute': 'Unmute',
    25         'Video Playback': 'Video Playback',
    26         'Volume': 'Volume',
    27         'Waiting': 'Waiting'
    28     }
     1var UIStringTable = {
     2    '##WIRELESS_PLAYBACK_DEVICE_TYPE##': 'AirPlay',
     3    '##WIRELESS_PLAYBACK_DEVICE_NAME##': 'This video is playing on “##DEVICE_NAME##”.',
     4
     5    '##TVOUT_DEVICE_TYPE##': 'TV Connected',
     6    '##TVOUT_DEVICE_NAME##': 'This video is playing on the TV.',
     7
     8    'Aborted': 'Aborted',
     9    'Audio Playback': 'Audio Playback',
     10    'Captions': 'Captions',
     11    'Display Full Screen': 'Display Full Screen',
     12    'Duration': 'Duration',
     13    'Elapsed': 'Elapsed',
     14    'Error': 'Error',
     15    'Exit Full Screen': 'Exit Full Screen',
     16    'Fast Forward': 'Fast Forward',
     17    'Loading': 'Loading',
     18    'Maximum Volume': 'Maximum Volume',
     19    'Minimum Volume': 'Minimum Volume',
     20    'Mute': 'Mute',
     21    'Pause': 'Pause',
     22    'Play': 'Play',
     23    'Remaining': 'Remaining',
     24    'Rewind': 'Rewind',
     25    'Rewind ##sec## Seconds': 'Rewind ##sec## Seconds',
     26    'Stalled': 'Stalled',
     27    'Subtitles': 'Subtitles',
     28    'Suspended': 'Suspended',
     29    'Unmute': 'Unmute',
     30    'Video Playback': 'Video Playback',
     31    'Volume': 'Volume',
     32    'Waiting': 'Waiting'
    2933};
  • trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js

    r167145 r167596  
    100100    },
    101101
    102     extend: function(child) {
     102    extend: function(child)
     103    {
    103104        for (var property in this) {
    104105            if (!child.hasOwnProperty(property))
     
    107108    },
    108109
    109     // Localized string accessor
    110     UIString: function(s){
    111         if (!this.localizedStrings)
    112             this.localizedStrings = mediaControlsLocalizedStrings();
    113 
    114         if (this.localizedStrings[s])
    115             return this.localizedStrings[s];
    116 
    117         console.error("Localized string \"" + s + "\" not found.");
     110    UIString: function(developmentString, replaceString, replacementString)
     111    {
     112        var localized = UIStringTable[developmentString];
     113        if (replaceString && replacementString)
     114            return localized.replace(replaceString, replacementString);
     115
     116        if (localized)
     117            return localized;
     118
     119        console.error("Localization for string \"" + developmentString + "\" not found.");
    118120        return "LOCALIZED STRING NOT FOUND";
    119121    },
     
    265267        var rewindButton = this.controls.rewindButton = document.createElement('button');
    266268        rewindButton.setAttribute('pseudo', '-webkit-media-controls-rewind-button');
    267         rewindButton.setAttribute('aria-label', this.UIString('Rewind %%sec%% Seconds').replace('%%sec%%', this.RewindAmount));
     269        rewindButton.setAttribute('aria-label', this.UIString('Rewind ##sec## Seconds', '##sec##', this.RewindAmount));
    268270        this.listenFor(rewindButton, 'click', this.handleRewindButtonClicked);
    269271
  • trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js

    r167145 r167596  
    6363    },
    6464
    65     UIString: function(s){
    66         var string = Controller.prototype.UIString.call(this, s);
    67         if (string)
    68             return string;
    69 
    70         if (!this.localizedStrings)
    71             this.localizedStrings = mediaControlsLocalizedStringsiOS();
    72 
    73         if (this.localizedStrings[s])
    74             return this.localizedStrings[s];
    75 
    76         console.error("Localized string \"" + s + "\" not found.");
    77         return "LOCALIZED STRING NOT FOUND";
    78     },
    79 
    8065    shouldHaveStartPlaybackButton: function() {
    8166        var allowsInline = this.host.mediaPlaybackAllowsInline;
     
    122107            var type = this.host.externalDeviceType;
    123108            if (type == "airplay") {
    124                 deviceType = this.UIString('##AIRPLAY_DEVICE_TYPE##');
    125                 deviceName = this.UIString('##AIRPLAY_DEVICE_NAME##').replace('##DEVICE_NAME##', this.host.externalDeviceDisplayName);
     109                deviceType = this.UIString('##WIRELESS_PLAYBACK_DEVICE_TYPE##');
     110                deviceName = this.UIString('##WIRELESS_PLAYBACK_DEVICE_NAME##', '##DEVICE_NAME##', this.host.externalDeviceDisplayName);
    126111            } else if (type == "tvout") {
    127112                deviceType = this.UIString('##TVOUT_DEVICE_TYPE##');
     
    425410
    426411Object.create(Controller.prototype).extend(ControllerIOS.prototype);
    427 Object.defineProperty(ControllerIOS.prototype, 'constructor', { enumerable:false, value:ControllerIOS });
     412Object.defineProperty(ControllerIOS.prototype, 'constructor', { enumerable: false, value: ControllerIOS });
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r167530 r167596  
    22912291                7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */; };
    22922292                7A1D7FCB18F85F0F00C385AD /* mediaControlsLocalizedStrings.js in Resources */ = {isa = PBXBuildFile; fileRef = 7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */; };
    2293                 7A1D7FCE18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js in Resources */ = {isa = PBXBuildFile; fileRef = 7A1D7FCC18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js */; };
    22942293                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */; };
    22952294                7A24587B1021EAF4000A00AA /* InspectorDOMAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A2458791021EAF4000A00AA /* InspectorDOMAgent.cpp */; };
     
    93289327                7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorFrontendHost.h; sourceTree = "<group>"; };
    93299328                7A1D7FCA18F85F0F00C385AD /* English */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = English; path = English.lproj/mediaControlsLocalizedStrings.js; sourceTree = SOURCE_ROOT; };
    9330                 7A1D7FCD18F86E5600C385AD /* English */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = English; path = English.lproj/mediaControlsLocalizedStringsiOS.js; sourceTree = SOURCE_ROOT; };
    93319329                7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorClient.cpp; sourceTree = "<group>"; };
    93329330                7A2458791021EAF4000A00AA /* InspectorDOMAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDOMAgent.cpp; sourceTree = "<group>"; };
     
    1460514603                        isa = PBXGroup;
    1460614604                        children = (
    14607                                 7A1D7FCC18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js */,
    14608                                 7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */,
    1460914605                                CD0DBB3E142274E600280263 /* audio */,
    1461014606                                65998A650E5F5FD3004E097A /* images */,
     
    1462314619                                85136C8C0AED665800F90A3D /* linkCursor.png */,
    1462414620                                BCAD1808131C7A0D00990406 /* Localizable.strings */,
     14621                                7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */,
    1462514622                                93153BE114195A5700FCF5BE /* missingImage.png */,
    1462614623                                93153BD914181F7A00FCF5BE /* missingImage@2x.png */,
     
    2644826445                        buildActionMask = 2147483647;
    2644926446                        files = (
    26450                                 7A1D7FCE18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js in Resources */,
    2645126447                                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
    2645226448                                46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
     
    2959129587                        sourceTree = "<group>";
    2959229588                };
    29593                 7A1D7FCC18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js */ = {
    29594                         isa = PBXVariantGroup;
    29595                         children = (
    29596                                 7A1D7FCD18F86E5600C385AD /* English */,
    29597                         );
    29598                         name = mediaControlsLocalizedStringsiOS.js;
    29599                         sourceTree = "<group>";
    29600                 };
    2960129589                BCAD1808131C7A0D00990406 /* Localizable.strings */ = {
    2960229590                        isa = PBXVariantGroup;
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r167145 r167596  
    12271227        scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsLocalizedStrings" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
    12281228        scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsApple" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
    1229         scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsLocalizedStringsiOS" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
    12301229        scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsiOS" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
    12311230        m_mediaControlsScript = scriptBuilder.toString();
Note: See TracChangeset for help on using the changeset viewer.