]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use SN.msg() and onEndScriptMessages() to export localized UI messages from Realtime...
authorBrion Vibber <brion@pobox.com>
Tue, 2 Nov 2010 20:12:58 +0000 (13:12 -0700)
committerBrion Vibber <brion@pobox.com>
Tue, 2 Nov 2010 20:12:58 +0000 (13:12 -0700)
lib/action.php
plugins/Realtime/RealtimePlugin.php
plugins/Realtime/realtimeupdate.js

index becd734b103cab4b80dd579bfd17f4217ccc515a..766cfca2699aa0b390dfb31de4ef66f748e59c88 100644 (file)
@@ -311,10 +311,10 @@ class Action extends HTMLOutputter // lawsuit
 
             $messages = array_merge($messages, $this->getScriptMessages());
         }
+        Event::handle('EndScriptMessages', array($this, &$messages));
         if ($messages) {
             $this->inlineScript('SN.messages=' . json_encode($messages));
         }
-        Event::handle('EndScriptMessages', array($this, &$messages));
         return $messages;
     }
 
index 7a40cdca319f57b9fe118c37798d6718ceb18e6e..479e8cef2f34dd2bcadb81a2bb45f06f117f62ad 100644 (file)
@@ -106,9 +106,7 @@ class RealtimePlugin extends Plugin
             $realtimeUI = ' RealtimeUpdate.initActions("'.$url.'", "'.$timeline.'", "'. $pluginPath .'");';
         }
 
-        $i18n = $this->_getMessages();
         $script = ' $(document).ready(function() { '.
-          'RealtimeUpdate._messages=' . json_encode($i18n) . ';' .
           $realtimeUI.
           $this->_updateInitialize($timeline, $user_id).
           '}); ';
@@ -329,25 +327,29 @@ class RealtimePlugin extends Plugin
     }
 
     /**
-     * Any i18n messages that need to be loaded at runtime.
-     * @return array of string key to output text string pairs
+     * Export any i18n messages that need to be loaded at runtime...
+     *
+     * @param Action $action
+     * @param array $messages
+     *
+     * @return boolean hook return value
      */
-    function _getMessages()
+    function onEndScriptMessages($action, &$messages)
     {
-        return array(
-            // TRANS: Text label for realtime view "play" button, usually replaced by an icon.
-            'play' => _m('BUTTON', 'Play'),
-            // TRANS: Tooltip for realtime view "play" button.
-            'play_tooltip' => _m('TOOLTIP', 'Play'),
-            // TRANS: Text label for realtime view "pause" button
-            'pause' => _m('BUTTON', 'Pause'),
-            // TRANS: Tooltip for realtime view "pause" button
-            'pause_tooltip' => _m('TOOLTIP', 'Pause'),
-            // TRANS: Text label for realtime view "popup" button, usually replaced by an icon.
-            'popup' => _m('BUTTON', 'Pop up'),
-            // TRANS: Tooltip for realtime view "popup" button.
-            'popup_tooltip' => _m('TOOLTIP', 'Pop up in a window'),
-        );
+        // TRANS: Text label for realtime view "play" button, usually replaced by an icon.
+        $messages['realtime_play'] = _m('BUTTON', 'Play');
+        // TRANS: Tooltip for realtime view "play" button.
+        $messages['realtime_play_tooltip'] = _m('TOOLTIP', 'Play');
+        // TRANS: Text label for realtime view "pause" button
+        $messages['realtime_pause'] = _m('BUTTON', 'Pause');
+        // TRANS: Tooltip for realtime view "pause" button
+        $messages['realtime_pause_tooltip'] = _m('TOOLTIP', 'Pause');
+        // TRANS: Text label for realtime view "popup" button, usually replaced by an icon.
+        $messages['realtime_popup'] = _m('BUTTON', 'Pop up');
+        // TRANS: Tooltip for realtime view "popup" button.
+        $messages['realtime_popup_tooltip'] = _m('TOOLTIP', 'Pop up in a window');
+
+        return true;
     }
 
     function _updateInitialize($timeline, $user_id)
index f764ca738db14bc457341def6681ccedaeef051c..f49cef95e6c50334cedbba8100289f108ad30e6d 100644 (file)
@@ -40,7 +40,6 @@ RealtimeUpdate = {
      _documenttitle: '',
      _paused:false,
      _queuedNotices:[],
-     _messages:{},
 
      init: function(userid, replyurl, favorurl, repeaturl, deleteurl)
      {
@@ -263,8 +262,8 @@ RealtimeUpdate = {
 
         $('#realtime_playpause').remove();
         $('#realtime_actions').prepend('<li id="realtime_playpause"><button id="realtime_pause" class="pause"></button></li>');
-        $('#realtime_pause').text(RealtimeUpdate._messages['pause'])
-                            .attr('title', RealtimeUpdate._messages['pause_tooltip'])
+        $('#realtime_pause').text(SN.msg('realtime_pause'))
+                            .attr('title', SN.msg('realtime_pause_tooltip'))
                             .bind('click', function() {
             RealtimeUpdate.removeNoticesHover();
             RealtimeUpdate.showPlay();
@@ -277,8 +276,8 @@ RealtimeUpdate = {
         RealtimeUpdate.setPause(true);
         $('#realtime_playpause').remove();
         $('#realtime_actions').prepend('<li id="realtime_playpause"><span id="queued_counter"></span> <button id="realtime_play" class="play"></button></li>');
-        $('#realtime_play').text(RealtimeUpdate._messages['play'])
-                           .attr('title', RealtimeUpdate._messages['play_tooltip'])
+        $('#realtime_play').text(SN.msg('realtime_play'))
+                           .attr('title', SN.msg('realtime_play_tooltip'))
                            .bind('click', function() {
             RealtimeUpdate.showPause();
             return false;
@@ -338,8 +337,8 @@ RealtimeUpdate = {
      initAddPopup: function(url, timeline, path)
      {
          $('#realtime_timeline').append('<button id="realtime_popup"></button>');
-         $('#realtime_popup').text(RealtimeUpdate._messages['popup'])
-                             .attr('title', RealtimeUpdate._messages['popup_tooltip'])
+         $('#realtime_popup').text(SN.msg('realtime_popup'))
+                             .attr('title', SN.msg('realtime_popup_tooltip'))
                              .bind('click', function() {
                 window.open(url,
                          '',