Skip to content

Commit

Permalink
Added localization support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartlomiej Laczkowski committed Dec 8, 2016
1 parent a6a5db0 commit a7fd784
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 138 deletions.
2 changes: 1 addition & 1 deletion chrome.manifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
content zend-debugger-toolbar content/
overlay chrome://browser/content/browser.xul chrome://zend-debugger-toolbar/content/toolbar.xul
overlay chrome://navigator/content/navigator.xul chrome://zend-debugger-toolbar/content/toolbar.xul
locale zend-debugger-toolbar none locale/none/
locale zend-debugger-toolbar en-US locale/en-US/
14 changes: 8 additions & 6 deletions content/about.xul
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zend-debugger-toolbar/content/about.css" type="text/css"?>

<dialog buttons="accept" id="zend-about-dialog" title="Zend Debugger Toolbar" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!DOCTYPE window SYSTEM "chrome://zend-debugger-toolbar/locale/about.dtd">

<dialog buttons="accept" id="zend-about-dialog" title="&title.dialog;" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://zend-debugger-toolbar/content/about.js"/>
<vbox id="zend-about-details">
<hbox>
<vbox>
<hbox>
<description value="Zend Debugger Toolbar" class="name"/>
<description value="&label.zend_debugger_toolbar;" class="name"/>
<description class="name">3.0</description>
</hbox>
<description value="Author(s)" class="title"/>
<description>Zend Technologies Ltd - Initial API and implementation</description>
<description value="&label.authors_title;" class="title"/>
<description>&label.authors_description;</description>
</vbox>
<spacer flex="1"/>
<vbox>
<image src="chrome://zend-debugger-toolbar/content/images/zde_icon48.png"/>
<spacer flex="1"/>
</vbox>
</hbox>
<description value="Project Page" class="title"/>
<description value="&label.project_page;" class="title"/>
<description onclick="zend_visitProjectPage()" class="url">https://github.com/zendtech/zend-debugger-firefox</description>
<description value="Zend Home Page" class="title"/>
<description value="&label.home_page;" class="title"/>
<description onclick="zend_visitHomePage()" class="url">http://www.zend.com</description>
</vbox>
<separator class="groove" id="zend-about-separator"/>
Expand Down
6 changes: 4 additions & 2 deletions content/frames.xul
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<dialog id="zendFramesDialog" title="Frame selection"
<!DOCTYPE window SYSTEM "chrome://zend-debugger-toolbar/locale/frames.dtd">

<dialog id="zendFramesDialog" title="&title.dialog;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="accept,cancel"
ondialogaccept="return zendSaveResult();"
ondialogcancel="return onCancel();">
<text id="zendFramesText" value="Select the frame you would like to debug/profile:"/>
<text id="zendFramesText" value="&label.select_frame_to_debug;"/>
<separator orient="horizontal" flex="1" />
<menulist id="zendFrames" minwidth="150" width="150">
<menupopup onpopuphiding="" editable="false"/>
Expand Down
89 changes: 25 additions & 64 deletions content/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@
* Contributor(s): Zend Technologies - initial API and implementation
******************************************************************************/

/**
* Array with host IPs.
*/
var zendDetectedIPs = [ "127.0.0.1" ];
/**
* DNS lookup listener.
*/
var zendOnDNSLookupListener = {
onLookupComplete : function(request, record, status) {
while (record.hasMore()) {
zendDetectedIPs.push(record.getNextAddrAsString());
}
}
};

/**
* Returns preference branch related to Zend Debugger Toolbar settings.
*
Expand Down Expand Up @@ -115,30 +100,10 @@ function zendGetZDEEnableFrameSelect() {
/**
* Returns 'debugHost' IP preference value.
*
* @param ask
* if <code>true</code>, a prompt message dialog for providing IP
* value will be shown if related preference has no value.
* @returns debug host IP preference value
*/
function zendGetZDEIP(ask) {
var ip = zendGetZDEPrefs().getCharPref("debugHost");
if (!ask) {
return ip;
}
if (ip == "" || ip == null) {
var message = "Please enter the Zend Debugger client IP address.\n";
if (zendDetectedIPs.length > 0) {
message += "\nThe following IP addresses have been detected:\n\n";
var i;
for (i = 0; i < zendDetectedIPs.length; i++) {
message += "\u2022 " + zendDetectedIPs[i] + "\n";
}
message += "\n";
}
ip = prompt(message, "");
}
zendGetZDEPrefs().setCharPref("debugHost", ip);
return ip;
function zendGetZDEIP() {
return zendGetZDEPrefs().getCharPref("debugHost");
}

/**
Expand All @@ -162,7 +127,7 @@ function zendLoadSettings() {
document.getElementById("zendSettingsFirstLine").checked = zendGetZDEFirstLine();
document.getElementById("zendSettingsEnableFrameSelect").checked = zendGetZDEEnableFrameSelect();
document.getElementById("zendSettingsAutodetectPort").value = zendGetZDEAutodetectPort();
document.getElementById("zendSettingsIP").value = zendGetZDEIP(false);
document.getElementById("zendSettingsIP").value = zendGetZDEIP();
document.getElementById("zendSettingsPort").value = zendGetZDEPort();
document.getElementById("zendSettingsUseSSL").checked = zendGetZDEUseSSL();
if (zendGetZDEAutodetect())
Expand All @@ -189,17 +154,6 @@ function zendSaveSettings() {
prefs.setBoolPref("useSSL", document.getElementById("zendSettingsUseSSL").checked);
}

/**
* Detects host IP(s) with the use of DNS service.
*/
function zendDetectIPs() {
var dnsService = Components.classes["@mozilla.org/network/dns-service;1"]
.getService(Components.interfaces.nsIDNSService);
if (dnsService != null) {
dnsService.asyncResolve(dnsService.myHostName, dnsService.RESOLVE_DISABLE_IPV6, zendOnDNSLookupListener, null);
}
}

/**
* Disables/enables GUI elements in 'Settings' frame, that depends on 'Manual
* Settings'/'Auto Detect Settings' radio buttons state.
Expand Down Expand Up @@ -228,21 +182,28 @@ function zendTestAutoDetect() {
if (document.getElementById("zendSettingsAutodetectTest").disabled) {
return;
}
var ZDE_Autodetect = zendGetZDEAutodetect();
var ZDE_BroadcastPort = zendGetZDEAutodetectPort();
var prefs = zendGetZDEPrefs();
// Save current auto-detect preferences for the test time
prefs.setBoolPref("autodetectSettings", true);
prefs.setCharPref("autodetectPort", document.getElementById("zendSettingsAutodetectPort").value);
document.getElementById("zendSettingsAutodetectTest").disabled = true;
zendFetchConnectionSettings(function(connectionProps) {
// Show success message here, failures are handled in callback owner
if (connectionProps.get("dbg-valid")) {
alert("Success!\n\nDebug connection settings can be automatically detected.");
var broadcastPort = document.getElementById("zendSettingsAutodetectPort").value;
var url = "http://127.0.0.1:" + broadcastPort;
var stringsBundle = document.getElementById("zdt-settings-messages");
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
document.getElementById("zendSettingsAutodetectTest").disabled = false;
if (this.status != 200) {
alert(stringsBundle.getString('messageConnectionTestFailure') + ' ' + broadcastPort);
return;
}
if (this.responseText != null) {
var response = this.responseText;
if (response.includes("debug_port") && response.includes("debug_host")) {
alert(stringsBundle.getString('messageConnectionTestSuccess') + ' ' + broadcastPort);
return;
}
}
alert(stringsBundle.getString('messageConnectionTestFailure') + ' ' + broadcastPort);
}
document.getElementById("zendSettingsAutodetectTest").disabled = false;
// Bring back auto-detect preferences
prefs.setBoolPref("autodetectSettings", ZDE_Autodetect);
prefs.setCharPref("autodetectPort", ZDE_BroadcastPort);
});
};
xhttp.open("GET", url, true);
xhttp.send();
}
42 changes: 24 additions & 18 deletions content/settings.xul
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" title="Zend Debugger Toolbar Settings" onload="zendLoadSettings();" id="zendSettings" orient="vertical" ondialogaccept="zendSaveSettings(); return true;" buttons="accept,cancel">
<!DOCTYPE window SYSTEM "chrome://zend-debugger-toolbar/locale/settings.dtd">

<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" title="&title.dialog;" onload="zendLoadSettings();" id="zendSettings" orient="vertical" ondialogaccept="zendSaveSettings(); return true;" buttons="accept,cancel">

<stringbundleset id="stringbundleset">
<stringbundle id="zdt-settings-messages" src="chrome://zend-debugger-toolbar/locale/settings.properties"/>
</stringbundleset>

<script type="application/x-javascript" src="chrome://zend-debugger-toolbar/content/settings.js"/>
<script type="application/x-javascript" src="chrome://zend-debugger-toolbar/content/toolbar.js"/>

<command id="cmd_zendToggleAutoDetect" oncommand="zendToggleAutoDetect()" />

<vbox flex="0">
<groupbox id="zendSettingsGeneral"><caption label="General"/>
<checkbox id="zendSettingsSearch" label="Enable Search Toolbar" />
<groupbox id="zendSettingsGeneral"><caption label="&label.general;"/>
<checkbox id="zendSettingsSearch" label="&label.enable_search;" />
</groupbox>

<groupbox orient="vertical"><caption label="Debug Session Settings"/>
<checkbox id="zendSettingsLocal" label="Debug Local Copy (if available)" />
<checkbox id="zendSettingsFirstLine" label="Break at First Line" />
<checkbox id="zendSettingsEnableFrameSelect" label="Enable Frame Selection" />
<groupbox orient="vertical"><caption label="&label.debug_settings;"/>
<checkbox id="zendSettingsLocal" label="&label.debug_local_copy;" />
<checkbox id="zendSettingsFirstLine" label="&label.break_at_first_line;" />
<checkbox id="zendSettingsEnableFrameSelect" label="&label.enable_frame_selection;" />
</groupbox>
</vbox>

<groupbox orient="vertical"><caption label="Client Settings"/>
<groupbox orient="vertical"><caption label="&label.client_ide_settings;"/>
<radiogroup id="zendSettingsRadio">
<hbox>
<radio label="Auto Detect Settings" id="zendSettingsAutodetect" command="cmd_zendToggleAutoDetect" selected="true"/>
<spacer flex="1"/>
<button label="Test"
<button label="&label.test;"
onclick="zendTestAutoDetect();"
tooltiptext="Test the auto detection server"
tooltiptext="&tooltip.test;"
id="zendSettingsAutodetectTest"/>
</hbox>
<hbox>
<separator orient="vertical"/>
<label value="Broadcasting Port" id="zendSettingsAutodetectPortLbl"/>
<label value="&label.broadcasting_port;" id="zendSettingsAutodetectPortLbl"/>
<spacer flex="1"/>
<textbox id="zendSettingsAutodetectPort"/>
</hbox>
<radio label="Manual Settings" id="zendSettingsManual" command="cmd_zendToggleAutoDetect"/>
<radio label="&label.manual_settings;" id="zendSettingsManual" command="cmd_zendToggleAutoDetect"/>
<hbox>
<separator orient="vertical"/>
<label value="Debug Port" id="zendSettingsPortLbl"/>
<label value="&label.debug_port;" id="zendSettingsPortLbl"/>
<spacer flex="1"/>
<textbox id="zendSettingsPort"/>
</hbox>
<hbox>
<separator orient="vertical"/>
<label value="IP Address" id="zendSettingsIPLbl"/>
<label value="&label.ip_address;" id="zendSettingsIPLbl"/>
<spacer flex="1"/>
<textbox id="zendSettingsIP"/>
</hbox>
<hbox>
<separator orient="vertical"/>
<checkbox label="Encrypt Communications Using SSL" id="zendSettingsUseSSL"/>
<checkbox label="&label.encrypt_with_ssl;" id="zendSettingsUseSSL"/>
</hbox>
</radiogroup>
</groupbox>

<script type="application/x-javascript" src="chrome://zend-debugger-toolbar/content/settings.js"/>
<script type="application/x-javascript" src="chrome://zend-debugger-toolbar/content/toolbar.js"/>

</dialog>
Loading

0 comments on commit a7fd784

Please sign in to comment.