Title: [167596] trunk/Source/WebCore
Revision
167596
Author
[email protected]
Date
2014-04-21 11:06:20 -0700 (Mon, 21 Apr 2014)

Log 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.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (167595 => 167596)


--- trunk/Source/WebCore/ChangeLog	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/ChangeLog	2014-04-21 18:06:20 UTC (rev 167596)
@@ -1,3 +1,41 @@
+2014-04-18  Dean Jackson  <[email protected]>
+
+        [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.
+
 2014-04-21  Brent Fulgham  <[email protected]>
 
         [Win] Unreviewed build fix.

Modified: trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js (167595 => 167596)


--- trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js	2014-04-21 18:06:20 UTC (rev 167596)
@@ -1,29 +1,33 @@
-function mediaControlsLocalizedStrings() {
-    return {
-        'Aborted': 'Aborted',
-        'Audio Playback': 'Audio Playback',
-        'Captions': 'Captions',
-        'Display Full Screen': 'Display Full Screen',
-        'Duration': 'Duration',
-        'Elapsed': 'Elapsed',
-        'Error': 'Error',
-        'Exit Full Screen': 'Exit Full Screen',
-        'Fast Forward': 'Fast Forward',
-        'Loading': 'Loading',
-        'Maximum Volume': 'Maximum Volume',
-        'Minimum Volume': 'Minimum Volume',
-        'Mute': 'Mute',
-        'Pause': 'Pause',
-        'Play': 'Play',
-        'Remaining': 'Remaining',
-        'Rewind': 'Rewind',
-        'Rewind %%sec%% Seconds': 'Rewind %%sec%% Seconds',
-        'Stalled': 'Stalled',
-        'Subtitles': 'Subtitles',
-        'Suspended': 'Suspended',
-        'Unmute': 'Unmute',
-        'Video Playback': 'Video Playback',
-        'Volume': 'Volume',
-        'Waiting': 'Waiting'
-    }
+var UIStringTable = {
+    '##WIRELESS_PLAYBACK_DEVICE_TYPE##': 'AirPlay',
+    '##WIRELESS_PLAYBACK_DEVICE_NAME##': 'This video is playing on “##DEVICE_NAME##”.',
+
+    '##TVOUT_DEVICE_TYPE##': 'TV Connected',
+    '##TVOUT_DEVICE_NAME##': 'This video is playing on the TV.',
+
+    'Aborted': 'Aborted',
+    'Audio Playback': 'Audio Playback',
+    'Captions': 'Captions',
+    'Display Full Screen': 'Display Full Screen',
+    'Duration': 'Duration',
+    'Elapsed': 'Elapsed',
+    'Error': 'Error',
+    'Exit Full Screen': 'Exit Full Screen',
+    'Fast Forward': 'Fast Forward',
+    'Loading': 'Loading',
+    'Maximum Volume': 'Maximum Volume',
+    'Minimum Volume': 'Minimum Volume',
+    'Mute': 'Mute',
+    'Pause': 'Pause',
+    'Play': 'Play',
+    'Remaining': 'Remaining',
+    'Rewind': 'Rewind',
+    'Rewind ##sec## Seconds': 'Rewind ##sec## Seconds',
+    'Stalled': 'Stalled',
+    'Subtitles': 'Subtitles',
+    'Suspended': 'Suspended',
+    'Unmute': 'Unmute',
+    'Video Playback': 'Video Playback',
+    'Volume': 'Volume',
+    'Waiting': 'Waiting'
 };
\ No newline at end of file

Deleted: trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStringsiOS.js (167595 => 167596)


--- trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStringsiOS.js	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/English.lproj/mediaControlsLocalizedStringsiOS.js	2014-04-21 18:06:20 UTC (rev 167596)
@@ -1,9 +0,0 @@
-function mediaControlsLocalizedStringsiOS() {
-    return {
-        '##AIRPLAY_DEVICE_TYPE##': 'AirPlay',
-        '##AIRPLAY_DEVICE_NAME##': 'This video is playing on “##DEVICE_NAME##”.',
-
-        '##TVOUT_DEVICE_TYPE##': 'TV Connected',
-        '##TVOUT_DEVICE_NAME##': 'This video is playing on the TV.',
-    }
-};
\ No newline at end of file

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (167595 => 167596)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2014-04-21 18:06:20 UTC (rev 167596)
@@ -99,22 +99,24 @@
         down: 40
     },
 
-    extend: function(child) {
+    extend: function(child)
+    {
         for (var property in this) {
             if (!child.hasOwnProperty(property))
                 child[property] = this[property];
         }
     },
 
-    // Localized string accessor
-    UIString: function(s){
-        if (!this.localizedStrings)
-            this.localizedStrings = mediaControlsLocalizedStrings();
+    UIString: function(developmentString, replaceString, replacementString)
+    {
+        var localized = UIStringTable[developmentString];
+        if (replaceString && replacementString)
+            return localized.replace(replaceString, replacementString);
 
-        if (this.localizedStrings[s])
-            return this.localizedStrings[s];
+        if (localized)
+            return localized;
 
-        console.error("Localized string \"" + s + "\" not found.");
+        console.error("Localization for string \"" + developmentString + "\" not found.");
         return "LOCALIZED STRING NOT FOUND";
     },
 
@@ -264,7 +266,7 @@
 
         var rewindButton = this.controls.rewindButton = document.createElement('button');
         rewindButton.setAttribute('pseudo', '-webkit-media-controls-rewind-button');
-        rewindButton.setAttribute('aria-label', this.UIString('Rewind %%sec%% Seconds').replace('%%sec%%', this.RewindAmount));
+        rewindButton.setAttribute('aria-label', this.UIString('Rewind ##sec## Seconds', '##sec##', this.RewindAmount));
         this.listenFor(rewindButton, 'click', this.handleRewindButtonClicked);
 
         var seekBackButton = this.controls.seekBackButton = document.createElement('button');

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js (167595 => 167596)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.js	2014-04-21 18:06:20 UTC (rev 167596)
@@ -62,21 +62,6 @@
         this.stopListeningFor(this.base, 'mouseout', this.handleWrapperMouseOut);
     },
 
-    UIString: function(s){
-        var string = Controller.prototype.UIString.call(this, s);
-        if (string)
-            return string;
-
-        if (!this.localizedStrings)
-            this.localizedStrings = mediaControlsLocalizedStringsiOS();
-
-        if (this.localizedStrings[s])
-            return this.localizedStrings[s];
-
-        console.error("Localized string \"" + s + "\" not found.");
-        return "LOCALIZED STRING NOT FOUND";
-    },
-
     shouldHaveStartPlaybackButton: function() {
         var allowsInline = this.host.mediaPlaybackAllowsInline;
 
@@ -121,8 +106,8 @@
             var deviceType = "";
             var type = this.host.externalDeviceType;
             if (type == "airplay") {
-                deviceType = this.UIString('##AIRPLAY_DEVICE_TYPE##');
-                deviceName = this.UIString('##AIRPLAY_DEVICE_NAME##').replace('##DEVICE_NAME##', this.host.externalDeviceDisplayName);
+                deviceType = this.UIString('##WIRELESS_PLAYBACK_DEVICE_TYPE##');
+                deviceName = this.UIString('##WIRELESS_PLAYBACK_DEVICE_NAME##', '##DEVICE_NAME##', this.host.externalDeviceDisplayName);
             } else if (type == "tvout") {
                 deviceType = this.UIString('##TVOUT_DEVICE_TYPE##');
                 deviceName = this.UIString('##TVOUT_DEVICE_NAME##');
@@ -424,4 +409,4 @@
 };
 
 Object.create(Controller.prototype).extend(ControllerIOS.prototype);
-Object.defineProperty(ControllerIOS.prototype, 'constructor', { enumerable:false, value:ControllerIOS });
+Object.defineProperty(ControllerIOS.prototype, 'constructor', { enumerable: false, value: ControllerIOS });

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (167595 => 167596)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-04-21 18:06:20 UTC (rev 167596)
@@ -2290,7 +2290,6 @@
 		7A0E771E10C00DB100A0276E /* JSInspectorFrontendHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A0E771C10C00DB100A0276E /* JSInspectorFrontendHost.cpp */; };
 		7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */; };
 		7A1D7FCB18F85F0F00C385AD /* mediaControlsLocalizedStrings.js in Resources */ = {isa = PBXBuildFile; fileRef = 7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */; };
-		7A1D7FCE18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js in Resources */ = {isa = PBXBuildFile; fileRef = 7A1D7FCC18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js */; };
 		7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */; };
 		7A24587B1021EAF4000A00AA /* InspectorDOMAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A2458791021EAF4000A00AA /* InspectorDOMAgent.cpp */; };
 		7A24587C1021EAF4000A00AA /* InspectorDOMAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A24587A1021EAF4000A00AA /* InspectorDOMAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9327,7 +9326,6 @@
 		7A0E771C10C00DB100A0276E /* JSInspectorFrontendHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorFrontendHost.cpp; sourceTree = "<group>"; };
 		7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorFrontendHost.h; sourceTree = "<group>"; };
 		7A1D7FCA18F85F0F00C385AD /* English */ = {isa = PBXFileReference; lastKnownFileType = sourcecode._javascript_; name = English; path = English.lproj/mediaControlsLocalizedStrings.js; sourceTree = SOURCE_ROOT; };
-		7A1D7FCD18F86E5600C385AD /* English */ = {isa = PBXFileReference; lastKnownFileType = sourcecode._javascript_; name = English; path = English.lproj/mediaControlsLocalizedStringsiOS.js; sourceTree = SOURCE_ROOT; };
 		7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorClient.cpp; sourceTree = "<group>"; };
 		7A2458791021EAF4000A00AA /* InspectorDOMAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDOMAgent.cpp; sourceTree = "<group>"; };
 		7A24587A1021EAF4000A00AA /* InspectorDOMAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDOMAgent.h; sourceTree = "<group>"; };
@@ -14604,8 +14602,6 @@
 		089C1665FE841158C02AAC07 /* Resources */ = {
 			isa = PBXGroup;
 			children = (
-				7A1D7FCC18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js */,
-				7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */,
 				CD0DBB3E142274E600280263 /* audio */,
 				65998A650E5F5FD3004E097A /* images */,
 				46F9D5DA0B0D60170028EE36 /* aliasCursor.png */,
@@ -14622,6 +14618,7 @@
 				2D9F0E1214FF1CBF00BA0FF7 /* linearSRGB.icc */,
 				85136C8C0AED665800F90A3D /* linkCursor.png */,
 				BCAD1808131C7A0D00990406 /* Localizable.strings */,
+				7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */,
 				93153BE114195A5700FCF5BE /* missingImage.png */,
 				93153BD914181F7A00FCF5BE /* [email protected] */,
 				85136C8D0AED665800F90A3D /* moveCursor.png */,
@@ -26447,7 +26444,6 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				7A1D7FCE18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js in Resources */,
 				46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
 				46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
 				93153BDE141959F400FCF5BE /* deleteButton.png in Resources */,
@@ -29590,14 +29586,6 @@
 			name = mediaControlsLocalizedStrings.js;
 			sourceTree = "<group>";
 		};
-		7A1D7FCC18F86E5600C385AD /* mediaControlsLocalizedStringsiOS.js */ = {
-			isa = PBXVariantGroup;
-			children = (
-				7A1D7FCD18F86E5600C385AD /* English */,
-			);
-			name = mediaControlsLocalizedStringsiOS.js;
-			sourceTree = "<group>";
-		};
 		BCAD1808131C7A0D00990406 /* Localizable.strings */ = {
 			isa = PBXVariantGroup;
 			children = (

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (167595 => 167596)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2014-04-21 17:31:13 UTC (rev 167595)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2014-04-21 18:06:20 UTC (rev 167596)
@@ -1226,7 +1226,6 @@
         StringBuilder scriptBuilder;
         scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsLocalizedStrings" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
         scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsApple" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
-        scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsLocalizedStringsiOS" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
         scriptBuilder.append([NSString stringWithContentsOfFile:[[NSBundle bundleForClass:[WebCoreRenderThemeBundle class]] pathForResource:@"mediaControlsiOS" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]);
         m_mediaControlsScript = scriptBuilder.toString();
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to