Starting on making Realtime plugin's UI messages localizable: pause/play, popup button text and tooltip text are now loaded from PHP code where we can get at gettext.
This commit is contained in:
parent
760a1c27bc
commit
151eebcc28
@ -106,7 +106,9 @@ class RealtimePlugin extends Plugin
|
|||||||
$realtimeUI = ' RealtimeUpdate.initActions("'.$url.'", "'.$timeline.'", "'. $pluginPath .'");';
|
$realtimeUI = ' RealtimeUpdate.initActions("'.$url.'", "'.$timeline.'", "'. $pluginPath .'");';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$i18n = $this->_getMessages();
|
||||||
$script = ' $(document).ready(function() { '.
|
$script = ' $(document).ready(function() { '.
|
||||||
|
'RealtimeUpdate._messages=' . json_encode($i18n) . ';' .
|
||||||
$realtimeUI.
|
$realtimeUI.
|
||||||
$this->_updateInitialize($timeline, $user_id).
|
$this->_updateInitialize($timeline, $user_id).
|
||||||
'}); ';
|
'}); ';
|
||||||
@ -326,6 +328,28 @@ class RealtimePlugin extends Plugin
|
|||||||
return array('plugins/Realtime/realtimeupdate.js');
|
return array('plugins/Realtime/realtimeupdate.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any i18n messages that need to be loaded at runtime.
|
||||||
|
* @return array of string key to output text string pairs
|
||||||
|
*/
|
||||||
|
function _getMessages()
|
||||||
|
{
|
||||||
|
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'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function _updateInitialize($timeline, $user_id)
|
function _updateInitialize($timeline, $user_id)
|
||||||
{
|
{
|
||||||
return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->repeaturl\", \"$this->deleteurl\"); ";
|
return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->repeaturl\", \"$this->deleteurl\"); ";
|
||||||
|
@ -40,6 +40,7 @@ RealtimeUpdate = {
|
|||||||
_documenttitle: '',
|
_documenttitle: '',
|
||||||
_paused:false,
|
_paused:false,
|
||||||
_queuedNotices:[],
|
_queuedNotices:[],
|
||||||
|
_messages:{},
|
||||||
|
|
||||||
init: function(userid, replyurl, favorurl, repeaturl, deleteurl)
|
init: function(userid, replyurl, favorurl, repeaturl, deleteurl)
|
||||||
{
|
{
|
||||||
@ -261,9 +262,10 @@ RealtimeUpdate = {
|
|||||||
RealtimeUpdate.addNoticesHover();
|
RealtimeUpdate.addNoticesHover();
|
||||||
|
|
||||||
$('#realtime_playpause').remove();
|
$('#realtime_playpause').remove();
|
||||||
$('#realtime_actions').prepend('<li id="realtime_playpause"><button id="realtime_pause" class="pause" title="Pause">Pause</button></li>');
|
$('#realtime_actions').prepend('<li id="realtime_playpause"><button id="realtime_pause" class="pause"></button></li>');
|
||||||
|
$('#realtime_pause').text(RealtimeUpdate._messages['pause'])
|
||||||
$('#realtime_pause').bind('click', function() {
|
.attr('title', RealtimeUpdate._messages['pause_tooltip'])
|
||||||
|
.bind('click', function() {
|
||||||
RealtimeUpdate.removeNoticesHover();
|
RealtimeUpdate.removeNoticesHover();
|
||||||
RealtimeUpdate.showPlay();
|
RealtimeUpdate.showPlay();
|
||||||
return false;
|
return false;
|
||||||
@ -274,9 +276,10 @@ RealtimeUpdate = {
|
|||||||
{
|
{
|
||||||
RealtimeUpdate.setPause(true);
|
RealtimeUpdate.setPause(true);
|
||||||
$('#realtime_playpause').remove();
|
$('#realtime_playpause').remove();
|
||||||
$('#realtime_actions').prepend('<li id="realtime_playpause"><span id="queued_counter"></span> <button id="realtime_play" class="play" title="Play">Play</button></li>');
|
$('#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'])
|
||||||
$('#realtime_play').bind('click', function() {
|
.attr('title', RealtimeUpdate._messages['play_tooltip'])
|
||||||
|
.bind('click', function() {
|
||||||
RealtimeUpdate.showPause();
|
RealtimeUpdate.showPause();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -334,10 +337,11 @@ RealtimeUpdate = {
|
|||||||
|
|
||||||
initAddPopup: function(url, timeline, path)
|
initAddPopup: function(url, timeline, path)
|
||||||
{
|
{
|
||||||
$('#realtime_timeline').append('<button id="realtime_popup" title="Pop up in a window">Pop up</button>');
|
$('#realtime_timeline').append('<button id="realtime_popup"></button>');
|
||||||
|
$('#realtime_popup').text(RealtimeUpdate._messages['popup'])
|
||||||
$('#realtime_popup').bind('click', function() {
|
.attr('title', RealtimeUpdate._messages['popup_tooltip'])
|
||||||
window.open(url,
|
.bind('click', function() {
|
||||||
|
window.open(url,
|
||||||
'',
|
'',
|
||||||
'toolbar=no,resizable=yes,scrollbars=yes,status=no,menubar=no,personalbar=no,location=no,width=500,height=550');
|
'toolbar=no,resizable=yes,scrollbars=yes,status=no,menubar=no,personalbar=no,location=no,width=500,height=550');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user