rem: toolbarItem.setAttribute("oncommand","if (event.target==this)   translateFrom('en_" + glanguagePairs[glocale][0] + "');"); 
add: toolbarItem.setAttribute("oncommand","if (event.target==this)   translateFrom(\'en_" + glanguagePairs[glocale][0] + "\');"); 
context: function initMenus()  //initialises the context menu and the toolbar menu{   var languagePair;         // set up context menu variables   var contextItem = document.getElementById("translate-context");      var contextMenuPopupElement = document.createElement("menupopup");      var contextMenuItemLabel;   var contextMenuItemTooltiptext;   var contextMenuItemOncommand;      var contextMenuItemElement;      //set up toolbar variables   var toolbarItem = document.getElementById("translate-pg");   var toolbarMenuPopupElement = document.createElement("menupopup");     var toolbarMenuItemLabel;   var toolbarMenuItemTooltiptext;   var toolbarMenuItemOncommand ;   var toolbarMenuItemElement;   var toolMenu = document.getElementById("translate-tool-menu");   var toolMenuSeperator = document.getElementById("translate-options-separator");      for(var i = 1; i < glanguagePairs[glocale].length ; i++)   {		languagePair = glanguagePairs[glocale][i] + "_" + glanguagePairs[glocale][0];    	    	    	//add menuitems to the  context menu    	contextMenuItemLabel = gTranslateBundle.getString("context.menu." + languagePair + ".label");   		contextMenuItemTooltiptext = 	gTranslateBundle.getString(languagePair + ".tooltip");    	contextMenuItemOncommand = "translateSelection('" + languagePair + "');";   		   		contextMenuItemElement = document.createElement("menuitem");    	    	contextMenuItemElement.setAttribute("label",contextMenuItemLabel);    	contextMenuItemElement.setAttribute("tooltiptext",contextMenuItemTooltiptext);    	contextMenuItemElement.setAttribute("oncommand",contextMenuItemOncommand);					contextMenuPopupElement.appendChild(contextMenuItemElement);					//add menuitems to the toolbutton menu		toolbarMenuItemLabel = gTranslateBundle.getString("toolbar.menu." + languagePair + ".label");      	toolbarMenuItemTooltiptext = 	gTranslateBundle.getString(languagePair + ".tooltip");    	toolbarMenuItemOncommand = "translateFrom('" + languagePair + "');";   		   		toolbarMenuItemElement = document.createElement("menuitem");   	    	toolbarMenuItemElement.setAttribute("label",toolbarMenuItemLabel);    	toolbarMenuItemElement.setAttribute("tooltiptext",toolbarMenuItemTooltiptext);    	toolbarMenuItemElement.setAttribute("oncommand",toolbarMenuItemOncommand);    	 						toolbarMenuPopupElement.appendChild(toolbarMenuItemElement);    }                    //set toolbar button class, which inturns sets the icon        toolbarItem.setAttribute("class","translate-tool-" + glanguagePairs[glocale][0]);         //setup quick translate  (english uses googles quick translate, all other languages default to english translation)    if(glocale == 0)    {    	toolbarItem.setAttribute("oncommand","if (event.target==this)   quick_translate();");    }    else    {    	toolbarItem.setAttribute("oncommand","if (event.target==this)   translateFrom('en_" + glanguagePairs[glocale][0] + "');");    }        // here's where we add menus if they aren't already there, if they are, then we remove them then add the new ones     if(contextItem.hasChildNodes())  //if Firefox has already started, then replace existing childnodes, otherwise append them    {     		contextItem.replaceChild(contextMenuPopupElement,contextItem.firstChild);    		toolbarItem.replaceChild(toolbarMenuPopupElement,toolbarItem.firstChild);    		    		    		// deals with adding languages to the tool menu, basically we add a clone of the toolbar menu.    		// Tricky part is to remove existing menuitems    		var toolChildren = toolMenu.childNodes;    		 	    	 	for (var i in toolChildren)    	 	{    	 		if(toolChildren[i].nodeName == "menuitem")    	 		{    	 			toolMenu.removeChild(toolChildren[i]);    	 		}    	 	}    	 	    	 	    		var cloneMenu = toolbarMenuPopupElement.cloneNode(true);  // use a clone because insertBefore moves elements and does NOT copy    		var nodeLength = cloneMenu.childNodes.length;    		for( var i = 0 ; i < nodeLength  ;i++)    		{    			toolMenu.insertBefore(cloneMenu.childNodes[0],toolMenuSeperator);    		}    		    	    		    }    else  	{  			// adds both context menu and toolbar menu     		  	contextItem.appendChild(contextMenuPopupElement);    		toolbarItem.appendChild(toolbarMenuPopupElement);     		    		// creates list of translation languages in the tool menu	    		var cloneMenu = toolbarMenuPopupElement.cloneNode(true);  // use a clone because insertBefore moves elements and does NOT copy    		var nodeLength = cloneMenu.childNodes.length;    		    		for( var i = 0 ; i < nodeLength  ;i++)    		{    			toolMenu.insertBefore(cloneMenu.childNodes[0],toolMenuSeperator);    		}            var langSelected = document.getElementById("langSelect");    		langSelected.childNodes[glocale].setAttribute("checked","true");   		  	}  	   }
meta: 9817	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9817/3dfc79e1d34082b523eea92d43db4e6d69e978f9/translate.js/buggy/trunk/chrome/content/translate.js