Permalink
Browse files

Merge branch 'web-gui-i18n' into next

  • Loading branch information...
bassosimone committed Jun 16, 2011
2 parents 75b6790 + 257a3af commit 9612fb8100bd41e7ce76ac1e0986858e270889c3
View
@@ -15,6 +15,9 @@ table {
tbody {
border-top: 1px solid rgb(204, 204, 204);
}
+.i18n {
+ visibility: hidden;
+}
.item-list ul {
margin: 0pt 0pt 0.75em;
padding: 0pt;
View
@@ -8,16 +8,16 @@
<!-- Again the usage of H4 here seems to me improper. -->
<div id="update">
- <h4 class='box-title'>Updates available</h4>
+ <h4 class='box-title i18n' id='i18n_updavailable'>Updates available</h4>
<p>
- Version <em><span id="updateVersion">(information not
- available)</span></em> is available for download from <em>
- <a id="updateUrl">(information not available)</a></em>.
+ Version <em><span id="updateVersion" class='i18n i18n_infonav'>(n/a)</span></em>
+ is available for download from <em>
+ <a id="updateUrl" class='i18n i18n_infonav'>(n/a)</a></em>.
</p>
</div>
<div id='statusBox'>
- <p>Neubot is: <span id='statusBoxSpan'>(n/a)</span>
+ <p><span class='i18n i18n_neubotis'>Neubot is</span>: <span id='statusBoxSpan' class='i18n i18n_infonav'>(n/a)</span>
<a id='statusBoxA' href='#' onclick='javascript: return false;'>enable/disable</a></p>
</div>
@@ -26,29 +26,33 @@ <h4 class='box-title'>Updates available</h4>
that needs some more separation between content and
presentation love. -->
<div id="testResultsBox">
- <h4 class='box-title'>Latest test details</h4>
+ <h4 class='box-title i18n i18n_latest'>Latest test details</h4>
<p id='box-results'>
- Result of <em><span id="testNameSideBar">(no tests yet)</span></em>
+ <span class='i18n i18n_resultof'>Result of</span> <em><span id="testNameSideBar" class='i18n i18n_infonav'>(no tests yet)</span></em>
<br /><span id="testTime"></span>
</p>
<dl>
<dt>
- <span class="help" title="Upper bound of the round-trip delay">Latency</span>
+ <span class="help i18n i18n_latency" title="Upper bound of the round-trip delay">Latency</span>
</dt>
<dd>
<span id="latencyResult">---</span>
</dd>
- <dt>Download speed</dt>
+ <dt>
+ <span class="i18n i18n_dlspeed">Download speed</span>
+ </dt>
<dd><span id="downloadResult">---</span></dd>
- <dt>Upload speed</dt>
+ <dt>
+ <span class="i18n i18n_ulspeed">Upload speed</span>
+ </dt>
<dd><span id="uploadResult">---</span></dd>
</dl>
</div>
<!-- Ok, so probably we should fix all H4s at once. -->
<div id="about">
- <h4>About</h4>
- <p>
+ <h4 class='i18n i18n_about'>About</h4>
+ <p class='i18n i18n_about_text'>
This is the web user interface of Neubot v0.3.7.
Neubot is a lightweight <a
href="http://www.neubot.org/copying">open-source</a> program
@@ -70,7 +74,7 @@ <h4>About</h4>
<hr />
- <div id="footer">
+ <div id="footer" class='i18n i18n_footer_text'>
Neubot is a research project on network neutrality of the<br />
<a href="http://nexa.polito.it/">NEXA Center for Internet &amp;
Society</a> at <a href="http://www.dauin.polito.it/">Politecnico
View
@@ -49,6 +49,7 @@
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/state.js"></script>
<script type="text/javascript" src="js/contrib.js"></script>
+ <script type="text/javascript" src="js/i18n.js"></script>
<title>Neubot 0.3.7 | Web interface</title>
@@ -75,22 +76,22 @@ <h2 class="hidden-tag">
</h2>
<ul class="k2menu" id='menu_tab_list'>
<li id='tab_index'>
- <a href="index.html" title="The status of the daemon" class="active">Status</a>
+ <a href="index.html" title="The status of the daemon" class='i18n active i18n_status'>Status</a>
</li>
<li id='tab_speedtest'>
- <a href="speedtest.html" title="Your recent speedtest results">Speedtest</a>
+ <a href="speedtest.html" title="Your recent speedtest results" class='i18n i18n_speedtest'>Speedtest</a>
</li>
<li id='tab_log'>
- <a href="log.html" title="Log">Log</a>
+ <a href="log.html" title="Log" class='i18n i18n_log'>Log</a>
</li>
<li id='tab_privacy'>
- <a href="privacy.html" title="Privacy">Privacy</a>
+ <a href="privacy.html" title="Privacy" class='i18n i18n_privacy'>Privacy</a>
</li>
<li id='tab_settings'>
- <a href="settings.html" title="Settings">Settings</a>
+ <a href="settings.html" title="Settings" class='i18n i18n_settings'>Settings</a>
</li>
<li id='tab_site'>
- <a href="http://www.neubot.org/" title="Go to Neubot web site">Neubot web site</a>
+ <a href="http://www.neubot.org/" title="Go to Neubot web site" class='i18n i18n_website'>Neubot web site</a>
</li>
</ul>
</div>
View
@@ -4,8 +4,8 @@
<div class="entry-content">
- <p>
- Thank you for using neubot! You are gaining some understanding
+ <p class='i18n i18n_welcome_text'>
+ Thank you for using Neubot! You are gaining some understanding
about your Internet Connection and helping the Internet Community
to understand what is going on in the network. This tab provides
a general overview of the status of the neubot daemon. Above there
@@ -15,9 +15,9 @@
</p>
<!-- It seems wrong to me to use H4 here -->
- <h4>Current Neubot status</h4>
+ <h4 class='i18n i18n_current_status'>Current Neubot status</h4>
- <p>
+ <p class='i18n i18n_status_text'>
This is the web interface to control the <em>neubot daemon</em>,
that is running in background with pid <em>
<span id="pid">(information not available)</span></em> since
@@ -32,15 +32,15 @@ <h4>Current Neubot status</h4>
<thead>
<tr>
<th></th>
- <th id="stateCol">State</th>
- <th>Description</th>
+ <th id="stateCol" class='i18n i18n_state'>State</th>
+ <th class='i18n i18n_description'>Description</th>
</tr>
</thead>
<tbody>
<tr id="idle">
<td></td>
<td>idle</td>
- <td>
+ <td class='i18n i18n_idle_status_text'>
The daemon is sleeping. The next rendezvous will
start in <em><span id="next_rendezvous">(information
not available)</span></em>.
@@ -49,15 +49,15 @@ <h4>Current Neubot status</h4>
<tr id="rendezvous">
<td></td>
<td>rendezvous</td>
- <td>
+ <td class='i18n i18n_rendezvous_status_text'>
The daemon is connecting to the <em>master server</em>
and retrieves test instructions and update information.
</td>
</tr>
<tr id="negotiate">
<td></td>
<td>negotiate</td>
- <td>
+ <td class='i18n i18n_negotiate_status_text'>
The daemon is waiting for its turn to perform a
transmission test. The last known position in queue
is <em><span id="queuePos">(no negotiations
@@ -67,7 +67,7 @@ <h4>Current Neubot status</h4>
<tr id="test">
<td></td>
<td>test</td>
- <td>
+ <td class='i18n i18n_test_status_text'>
The daemon is performing a transmission test. The
name of the test is <em><span id="testName">
(no tests yet)</span></em>.
@@ -76,7 +76,7 @@ <h4>Current Neubot status</h4>
<tr id="collect">
<td></td>
<td>collect</td>
- <td>
+ <td class='i18n i18n_collect_status_text'>
The daemon is uploading the results of the latest
transmission test to the neubot project servers.
</td>
@@ -87,9 +87,9 @@ <h4>Current Neubot status</h4>
<br />
<!-- It seems wrong to me to use H4 here -->
- <h4>How do I run a test <em>now</em>?</h4>
+ <h4 class='i18n i18n_testnow'>How do I run a test <em>now</em>?</h4>
- <p>The support for starting a test <em>now</em> is not
+ <p class='i18n i18n_testnow_text'>The support for starting a test <em>now</em> is not
yet implemented by this web user interface, but that is
in the TODO list. At the moment, the only way to run a
test <em>now</em> is to type the command <b><em>neubot
View
@@ -0,0 +1,87 @@
+/* neubot/www/js/i18n.js */
+/*-
+ * Copyright (c) 2011 Alessio Palmero Aprosio <alessio@apnetwork.it>,
+ * Universita' degli Studi di Milano
+ *
+ * This file is part of Neubot <http://www.neubot.org/>.
+ *
+ * Neubot is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Neubot is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Neubot. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+var LANG = {};
+
+var i18n = {
+ languages: {
+ it: 'Italian',
+ },
+
+ get: function(label) {
+ if (LANG[label]) {
+ return LANG[label];
+ }
+ else {
+ return label;
+ }
+ },
+
+ getLanguageInUse: function() {
+ var lang;
+ if (navigator.userLanguage) {
+ lang = navigator.userLanguage.toLowerCase();
+ }
+ else if (navigator.language) {
+ lang = navigator.language.toLowerCase();
+ }
+ else {
+ lang = undefined;
+ }
+ return lang;
+ },
+
+ translate: function() {
+ var lang = this.getLanguageInUse();
+ if (!lang || !this.languages[lang]) {
+ jQuery(".i18n").css("visibility", "visible");
+ return;
+ }
+
+ jQuery.ajax({
+ url: "lang/" + lang + ".js",
+ dataType: 'script',
+ success: function(data) {
+ jQuery(".i18n").each(function(index, element) {
+ var classList = jQuery(element).attr('class').split(/\s+/);
+ jQuery.each(classList, function(i, v) {
+ var patt = /^i18n_(.*)$/i;
+ if ((result = patt.exec(v)) && LANG[result[1]]) {
+ switch (element.tagName) {
+ case "textarea":
+ jQuery(element).text(LANG[result[1]]);
+ break;
+ default:
+ jQuery(element).html(LANG[result[1]]);
+ break;
+ }
+ }
+ });
+ });
+ jQuery(".i18n").css("visibility", "visible");
+ }
+ });
+ }
+};
+
+jQuery(document).ready(function() {
+ i18n.translate();
+});
View
@@ -40,8 +40,6 @@ var state = (function() {
}
function update_sidebar(data) {
- jQuery('#testResultsBox h4').text("Latest test details");
-
if (data.events.config) {
if (data.events.config.enabled != undefined) {
utils.setStatusLabels(data.events.config);
@@ -77,9 +75,11 @@ var state = (function() {
}
if (data.current == "test") {
jQuery('#testResultsBox').qtip("show");
+ jQuery('#testResultsBox h4').text(i18n.get("Current test results"));
}
else {
jQuery('#testResultsBox').qtip("hide");
+ jQuery('#testResultsBox h4').text(i18n.get("Latest test results"));
}
jQuery('table#state tr').css('background-color', 'transparent');
jQuery('table#state tr#' + data.current).css('background-color', '#ffc');
@@ -128,7 +128,7 @@ var state = (function() {
my.start = function() {
jQuery('#testResultsBox').qtip({
- content: "A new test is running.",
+ content: i18n.get("Test running"),
position: {
target: jQuery('#testTime'),
corner: {
View
@@ -122,18 +122,18 @@ var utils = (function() {
self.setStatusLabels = function(data) {
if (data.enabled == "1") {
- jQuery("#statusBoxSpan").html("enabled");
+ jQuery("#statusBoxSpan").html(i18n.get("enabled"));
jQuery("#statusBoxSpan").css("color", "#3DA64E");
- jQuery("#statusBoxA").html("Disable");
+ jQuery("#statusBoxA").html(i18n.get("Disable"));
jQuery("#statusBoxA").unbind('click');
jQuery("#statusBoxA").click(function () {
self.setConfigVars({'enabled': 0});
});
}
else {
- jQuery("#statusBoxSpan").html("disabled");
+ jQuery("#statusBoxSpan").html(i18n.get("disabled"));
jQuery("#statusBoxSpan").css("color", "#c00");
- jQuery("#statusBoxA").html("Enable");
+ jQuery("#statusBoxA").html(i18n.get("Enable"));
jQuery("#statusBoxA").unbind('click');
jQuery("#statusBoxA").click(function () {
self.setConfigVars({'enabled': 1});
Oops, something went wrong.

0 comments on commit 9612fb8

Please sign in to comment.