[Phpfreechat-svn] SF.net SVN: phpfreechat: [436] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-04-16 20:09:24
|
Revision: 436 Author: kerphi Date: 2006-04-16 13:09:13 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=436&view=rev Log Message: ----------- i18n refactoring client side rehash command improvments Modified Paths: -------------- trunk/src/commands/rehash.class.php trunk/src/phpfreechat.class.php trunk/themes/default/templates/pfcclient.js.tpl.php trunk/themes/default/templates/pfcgui.js.tpl.php trunk/themes/default/templates/style.css.tpl.php Added Paths: ----------- trunk/themes/default/templates/pfci18n.js.tpl.php Modified: trunk/src/commands/rehash.class.php =================================================================== --- trunk/src/commands/rehash.class.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/src/commands/rehash.class.php 2006-04-16 20:09:13 UTC (rev 436) @@ -15,6 +15,7 @@ { $c =& $this->c; $synchro = $c->synchronizeWithCache(true); // true => destroy the cache + if ($synchro) $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ko', '');"); else Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/src/phpfreechat.class.php 2006-04-16 20:09:13 UTC (rev 436) @@ -100,6 +100,8 @@ $t->assignObject($c,"c"); $t->assignObject($u,"u"); $output .= "<script type=\"text/javascript\">\n // <![CDATA[\n"; + $t->setTemplate($c->getFilePathFromTheme("templates/pfci18n.js.tpl.php")); + $output .= $t->getOutput(); $t->setTemplate($c->getFilePathFromTheme("templates/pfcgui.js.tpl.php")); $output .= $t->getOutput(); $t->setTemplate($c->getFilePathFromTheme("templates/pfcclient.js.tpl.php")); Modified: trunk/themes/default/templates/pfcclient.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcclient.js.tpl.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/themes/default/templates/pfcclient.js.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -9,9 +9,7 @@ pfcClient.prototype = { initialize: function() - { - this.gui = new pfcGui(); - + { /* user description */ this.nickname = '<?php echo $u->nick; ?>'; @@ -86,26 +84,27 @@ this.el_container.onmouseup = this.callbackContainer_OnMouseup.bindAsEventListener(this); document.body.onunload = this.callback_OnUnload.bindAsEventListener(this); - /* the i18n translations */ - var i18n = { - hide_nickname_color: '<?php echo _pfc("Hide nickname marker"); ?>', - show_nickname_color: '<?php echo _pfc("Show nickname marker"); ?>', - hide_clock: '<?php echo _pfc("Hide dates and hours"); ?>', - show_clock: '<?php echo _pfc("Show dates and hours"); ?>', - logout: '<?php echo _pfc("Disconnect"); ?>', - login: '<?php echo _pfc("Connect"); ?>', - maximize: '<?php echo _pfc("Magnify"); ?>', - minimize: '<?php echo _pfc("Cut down"); ?>', - hidesmiley: '<?php echo _pfc("Hide smiley box"); ?>', - showsmiley: '<?php echo _pfc("Show smiley box"); ?>', - hideonline: '<?php echo _pfc("Hide online users box"); ?>', - showonline: '<?php echo _pfc("Show online users box"); ?>', + // the i18n translations + this.i18n = new pfcI18N(); + this.i18n.setLabel('hide_nickname_color', '<?php echo _pfc("Hide nickname marker"); ?>'); + this.i18n.setLabel('show_nickname_color', '<?php echo _pfc("Show nickname marker"); ?>'); + this.i18n.setLabel('hide_clock', '<?php echo _pfc("Hide dates and hours"); ?>'); + this.i18n.setLabel('show_clock', '<?php echo _pfc("Show dates and hours"); ?>'); + this.i18n.setLabel('logout', '<?php echo _pfc("Disconnect"); ?>'); + this.i18n.setLabel('login', '<?php echo _pfc("Connect"); ?>'); + this.i18n.setLabel('maximize', '<?php echo _pfc("Magnify"); ?>'); + this.i18n.setLabel('minimize', '<?php echo _pfc("Cut down"); ?>'); + this.i18n.setLabel('hidesmiley', '<?php echo _pfc("Hide smiley box"); ?>'); + this.i18n.setLabel('showsmiley', '<?php echo _pfc("Show smiley box"); ?>'); + this.i18n.setLabel('hideonline', '<?php echo _pfc("Hide online users box"); ?>'); + this.i18n.setLabel('showonline', '<?php echo _pfc("Show online users box"); ?>'); + this.i18n.setLabel('enter_nickname', '<?php echo _pfc("Please enter your nickname"); ?>'); + this.i18n.setLabel('Private message', '<?php echo _pfc("Private message"); ?>'); + this.i18n.setLabel('Close this tab', '<?php echo _pfc("Close this tab"); ?>'); - enter_nickname: '<?php echo _pfc("Please enter your nickname"); ?>', - private_message: '<?php echo _pfc("Private message"); ?>' - }; - this.i18n = $H(i18n); - + // the graphical user interface + this.gui = new pfcGui(this.i18n); + /* the smileys */ var smileys = { <?php @@ -130,7 +129,7 @@ { // ask to choose a nickname if (nickname == '') nickname = this.nickname; - var newnick = prompt(this.i18n.enter_nickname, nickname); + var newnick = prompt(this.i18n._('enter_nickname'), nickname); if (newnick) this.sendRequest('/nick', newnick); }, @@ -304,11 +303,17 @@ } else if (cmd == "rehash") { + if (resp == "ok") + { + this.displayMsg( 'rehash', this.i18n._('Configuration has been rehashed') ); + } + else if (resp == "ko") + { + this.displayMsg( 'rehash', this.i18n._('A problem occurs during rehash') ); + } + } + else alert(cmd + "-"+resp+"-"+param); - } - - //if( cmd != "update") - // alert(cmd + "-"+resp+"-"+param); }, /** @@ -494,6 +499,20 @@ } }, + displayMsg: function( cmd, msg ) + { + // get the current selected tab container + var tabid = this.gui.getTabId(); + var container = this.gui.getChatContentFromTabId(tabid); + + // create a dummy div to avoid konqueror bug when setting nickmarkers + var m = document.createElement('div'); + m.innerHTML = '<pre class="<?php echo $prefix; ?>cmd_'+cmd+'">'+msg+'</pre>'; + // finaly append this to the message list + container.appendChild(m); + this.gui.scrollDown(tabid, m); + }, + handleComingRequest: function( cmds ) { var msg_html = $H(); @@ -560,28 +579,15 @@ var recipientid = keys[i]; var tabid = recipientid; - /* create the tab if it doesn't exists yet */ + // create the tab if it doesn't exists yet var recipientdiv = this.gui.getChatContentFromTabId(tabid); - /* create a dummy div to avoid konqueror bug when setting nickmarkers */ + // create a dummy div to avoid konqueror bug when setting nickmarkers var m = document.createElement('div'); m.innerHTML = msg_html[recipientid]; - /* finaly append this to the message list */ + // finaly append this to the message list recipientdiv.appendChild(m); - - // var a = msg_ids[recipientid]; - //alert(a.inspect()); - // for(var j = 0; j < msg_ids[recipientid].length ; j++) - { - - this.gui.scrollDown(tabid, m/*$('<?php echo $prefix; ?>msg'+ msg_ids[recipientid][j])*/); - - // colorize messages nicknames - //var root = $('<?php echo $prefix; ?>msg'+ msg_ids[j]); - //this.refresh_nickmarker(root); - //this.refresh_clock(root); - } - + this.gui.scrollDown(tabid, m); } }, @@ -645,7 +651,7 @@ // this is someone -> create a privmsg link var img = document.createElement('img'); img.setAttribute('src', '<?php echo $c->getFileUrlFromTheme('images/user.gif'); ?>'); - img.alt = this.i18n.private_message; + img.alt = this.i18n._('Private message'); img.title = img.alt; img.style.marginRight = '5px'; var a = document.createElement('a'); @@ -1009,7 +1015,7 @@ if (this.nickmarker) { nickmarker_icon.src = "<?php echo $c->getFileUrlFromTheme('images/color-on.gif'); ?>"; - nickmarker_icon.alt = this.i18n.hide_nickname_color; + nickmarker_icon.alt = this.i18n._('hide_nickname_color'); nickmarker_icon.title = nickmarker_icon.alt; this.colorizeNicks(root); this.colorizeNicks($('<?php echo $prefix; ?>online')); @@ -1017,7 +1023,7 @@ else { nickmarker_icon.src = "<?php echo $c->getFileUrlFromTheme('images/color-off.gif'); ?>"; - nickmarker_icon.alt = this.i18n.show_nickname_color; + nickmarker_icon.alt = this.i18n._('show_nickname_color'); nickmarker_icon.title = nickmarker_icon.alt; var elts = this.getElementsByClassName(root, '<?php echo $prefix; ?>nickmarker', ''); for(var i = 0; elts.length > i; i++) @@ -1056,7 +1062,7 @@ if (this.clock) { clock_icon.src = "<?php echo $c->getFileUrlFromTheme('images/clock-on.gif'); ?>"; - clock_icon.alt = this.i18n.hide_clock; + clock_icon.alt = this.i18n._('hide_clock'); clock_icon.title = clock_icon.alt; this.showClass(root, '<?php echo $prefix; ?>date', '<?php echo $prefix; ?>invisible', true); this.showClass(root, '<?php echo $prefix; ?>heure', '<?php echo $prefix; ?>invisible', true); @@ -1064,7 +1070,7 @@ else { clock_icon.src = "<?php echo $c->getFileUrlFromTheme('images/clock-off.gif'); ?>"; - clock_icon.alt = this.i18n.show_clock; + clock_icon.alt = this.i18n._('show_clock'); clock_icon.title = clock_icon.alt; this.showClass(root, '<?php echo $prefix; ?>date', '<?php echo $prefix; ?>invisible', false); this.showClass(root, '<?php echo $prefix; ?>heure', '<?php echo $prefix; ?>invisible', false); @@ -1091,7 +1097,7 @@ { // this.updateNickList(this.nicklist); loginlogout_icon.src = "<?php echo $c->getFileUrlFromTheme('images/logout.gif'); ?>"; - loginlogout_icon.alt = this.i18n.logout; + loginlogout_icon.alt = this.i18n._('logout'); loginlogout_icon.title = loginlogout_icon.alt; } else @@ -1099,7 +1105,7 @@ this.clearMessages(); this.clearNickList(); loginlogout_icon.src = "<?php echo $c->getFileUrlFromTheme('images/login.gif'); ?>"; - loginlogout_icon.alt = this.i18n.login; + loginlogout_icon.alt = this.i18n._('login'); loginlogout_icon.title = loginlogout_icon.alt; } }, @@ -1126,14 +1132,14 @@ if (this.minmax_status) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/maximize.gif'); ?>"; - btn.alt = this.i18n.maximize; + btn.alt = this.i18n._('maximize'); btn.title = btn.alt; content.style.display = 'none'; } else { btn.src = "<?php echo $c->getFileUrlFromTheme('images/minimize.gif'); ?>"; - btn.alt = this.i18n.minimize; + btn.alt = this.i18n._('minimize'); btn.title = btn.alt; content.style.display = 'block'; } @@ -1238,7 +1244,7 @@ if (btn) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/smiley-on.gif'); ?>"; - btn.alt = this.i18n.hidesmiley; + btn.alt = this.i18n._('hidesmiley'); btn.title = btn.alt; } content.style.display = 'block'; @@ -1248,7 +1254,7 @@ if (btn) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/smiley-off.gif'); ?>"; - btn.alt = this.i18n.showsmiley; + btn.alt = this.i18n._('showsmiley'); btn.title = btn.alt; } content.style.display = 'none'; @@ -1282,14 +1288,14 @@ if (this.showwhosonline) { btn.src = "<?php echo $c->getFileUrlFromTheme('images/online-on.gif'); ?>"; - btn.alt = this.i18n.hideonline; + btn.alt = this.i18n._('hideonline'); btn.title = btn.alt; content.style.display = 'block'; } else { btn.src = "<?php echo $c->getFileUrlFromTheme('images/online-off.gif'); ?>"; - btn.alt = this.i18n.showonline; + btn.alt = this.i18n._('showonline'); btn.title = btn.alt; content.style.display = 'none'; } Modified: trunk/themes/default/templates/pfcgui.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcgui.js.tpl.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/themes/default/templates/pfcgui.js.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -6,8 +6,10 @@ var pfcGui = Class.create(); pfcGui.prototype = { - initialize: function() + initialize: function(i18n) { + this.i18n = i18n; + this.current_tab = ''; this.current_tab_id = ''; this.tabs = Array(); @@ -211,7 +213,7 @@ var a2 = document.createElement('a'); a2.pfc_tabid = tabid; a2.onclick = function(){pfc.sendRequest('/leave', this.pfc_tabid); return false;} - a2.alt = '<?php echo _pfc("Close this tab"); ?>'; + a2.alt = this.i18n._('Close this tab'); a2.title = a2.alt; Element.addClassName(a2, '<?php echo $prefix; ?>tabclose'); var img = document.createElement('img'); Added: trunk/themes/default/templates/pfci18n.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfci18n.js.tpl.php (rev 0) +++ trunk/themes/default/templates/pfci18n.js.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -0,0 +1,40 @@ +/** + * This class centralize the pfc' translated messages + * (depends on prototype library) + * @author Stephane Gully + */ +var pfcI18N = Class.create(); +pfcI18N.prototype = { + + initialize: function() + { + this.labels = $H(); + this.elts = $H(); + }, + + setLabel: function(key, value) + { + this.labels[key] = value; + }, + + _: function(key, param) + { + if (this.labels[key]) + return this.labels[key]; + else + return '_'+key+'_'; + }, + + /** + * Register element can be used to change dynamicaly the client language + */ + registerElement: function(key, element, attribute) + { + // store the assigned element + element = $(element); + if (!this.elts[key]) + this.elts[key] = [ [element, attribute] ]; + else + this.elts[key].push( [element, attribute] ); + } +}; Modified: trunk/themes/default/templates/style.css.tpl.php =================================================================== --- trunk/themes/default/templates/style.css.tpl.php 2006-04-16 17:00:59 UTC (rev 435) +++ trunk/themes/default/templates/style.css.tpl.php 2006-04-16 20:09:13 UTC (rev 436) @@ -231,6 +231,12 @@ font-style: italic; color: #888; } +pre.<?php echo $prefix; ?>cmd_rehash, +pre.<?php echo $prefix; ?>cmd_help +{ + color: #888; + font-style: italic; +} div#<?php echo $prefix; ?>colorlist { display: none; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |