WebUI: Improve translation macro.

Now we use QBT_TR(translatable string)QBT_TR.
This commit is contained in:
Vladimir Golovnev (Glassez)
2014-12-17 14:58:32 +03:00
parent f43d8f1139
commit d80a14a2e1
21 changed files with 272 additions and 272 deletions

View File

@@ -139,7 +139,7 @@ window.addEvent('load', function () {
noCache : true,
method : 'get',
onFailure : function () {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR');
clearTimeout(loadTorrentsInfoTimer);
loadTorrentsInfoTimer = loadTorrentsInfo.delay(2000);
},
@@ -242,7 +242,7 @@ window.addEvent('load', function () {
noCache : true,
method : 'get',
onFailure : function () {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR');
clearTimeout(loadTransferInfoTimer);
loadTransferInfoTimer = loadTransferInfo.delay(4000);
},
@@ -261,10 +261,10 @@ window.addEvent('load', function () {
transfer_info += " (" + friendlyUnit(info.up_info_data, false) + ")"
$("UpInfos").set('html', transfer_info);
if (speedInTitle)
document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
document.title = "QBT_TR(D:%1 U:%2)QBT_TR".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
else
document.title = "_(qBittorrent web User Interface)";
$('DHTNodes').set('html', '_(DHT: %1 nodes)'.replace("%1", info.dht_nodes));
document.title = "QBT_TR(qBittorrent web User Interface)QBT_TR";
$('DHTNodes').set('html', 'QBT_TR(DHT: %1 nodes)QBT_TR'.replace("%1", info.dht_nodes));
if (info.connection_status == "connected")
$('connectionStatus').src = 'images/skin/connected.png';
else if (info.connection_status == "firewalled")

View File

@@ -3,22 +3,22 @@
*/
function friendlyUnit(value, isSpeed) {
units = [
"_(B)",
"_(KiB)",
"_(MiB)",
"_(GiB)",
"_(TiB)",
"QBT_TR(B)QBT_TR",
"QBT_TR(KiB)QBT_TR",
"QBT_TR(MiB)QBT_TR",
"QBT_TR(GiB)QBT_TR",
"QBT_TR(TiB)QBT_TR",
];
if (value < 0)
return "_(Unknown)";
return "QBT_TR(Unknown)QBT_TR";
var i = 0;
while (value >= 1024. && i++ < 6)
value /= 1024.;
var ret;
ret = value.toFixed(1) + " " + units[i];
if (isSpeed)
ret += "_(/s)";
ret += "QBT_TR(/s)QBT_TR";
return ret;
}
@@ -32,18 +32,18 @@ function friendlyDuration(seconds) {
if (seconds == 0)
return "0";
if (seconds < 60)
return "< " + "_(%1m)".replace("%1", "1"); //translation of "< 1m" not working
return "< " + "QBT_TR(%1m)QBT_TR".replace("%1", "1"); //translation of "< 1m" not working
var minutes = seconds / 60;
if (minutes < 60)
return "_(%1m)".replace("%1", parseInt(minutes));
return "QBT_TR(%1m)QBT_TR".replace("%1", parseInt(minutes));
var hours = minutes / 60;
minutes = minutes - hours * 60;
if (hours < 24)
return "_(%1h %2m)".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes))
return "QBT_TR(%1h %2m)QBT_TR".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes))
var days = hours / 24;
hours = hours - days * 24;
if (days < 100)
return "_(%1d %2h)".replace("%1", parseInt(days)).replace("%2", parseInt(hours))
return "QBT_TR(%1d %2h)QBT_TR".replace("%1", parseInt(days)).replace("%2", parseInt(hours))
return "∞";
}

View File

@@ -43,7 +43,7 @@ initializeWindows = function() {
new Event(e).stop();
new MochaUI.Window({
id: 'downloadPage',
title: "_(Download from urls)",
title: "QBT_TR(Download from urls)QBT_TR",
loadMethod: 'iframe',
contentURL: 'download.html',
scrollbars: true,
@@ -62,7 +62,7 @@ initializeWindows = function() {
new Event(e).stop();
new MochaUI.Window({
id: 'preferencesPage',
title: "_(Options)",
title: "QBT_TR(Options)QBT_TR",
loadMethod: 'xhr',
toolbar: true,
contentURL: 'preferences_content.html',
@@ -84,7 +84,7 @@ initializeWindows = function() {
new Event(e).stop();
new MochaUI.Window({
id: 'uploadPage',
title: "_(Download local torrent)",
title: "QBT_TR(Download local torrent)QBT_TR",
loadMethod: 'iframe',
contentURL: 'upload.html',
scrollbars: true,
@@ -101,7 +101,7 @@ initializeWindows = function() {
globalUploadLimitFN = function() {
new MochaUI.Window({
id: 'uploadLimitPage',
title: "_(Global Upload Speed Limit)",
title: "QBT_TR(Global Upload Speed Limit)QBT_TR",
loadMethod: 'iframe',
contentURL: 'uploadlimit.html?hash=global',
scrollbars: false,
@@ -120,7 +120,7 @@ initializeWindows = function() {
var hash = h[0];
new MochaUI.Window({
id: 'uploadLimitPage',
title: "_(Torrent Upload Speed Limiting)",
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR",
loadMethod: 'iframe',
contentURL: 'uploadlimit.html?hash=' + hash,
scrollbars: false,
@@ -165,7 +165,7 @@ initializeWindows = function() {
globalDownloadLimitFN = function() {
new MochaUI.Window({
id: 'downloadLimitPage',
title: "_(Global Download Speed Limit)",
title: "QBT_TR(Global Download Speed Limit)QBT_TR",
loadMethod: 'iframe',
contentURL: 'downloadlimit.html?hash=global',
scrollbars: false,
@@ -184,7 +184,7 @@ initializeWindows = function() {
var hash = h[0];
new MochaUI.Window({
id: 'downloadLimitPage',
title: "_(Torrent Download Speed Limiting)",
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR",
loadMethod: 'iframe',
contentURL: 'downloadlimit.html?hash=' + hash,
scrollbars: false,
@@ -200,7 +200,7 @@ initializeWindows = function() {
deleteFN = function() {
var h = myTable.selectedIds();
/*if(h.length && confirm('_(Are you sure you want to delete the selected torrents from the transfer list?)')) {
/*if(h.length && confirm('QBT_TR(Are you sure you want to delete the selected torrents from the transfer list?)QBT_TR')) {
h.each(function(item, index){
new Request({url: 'command/delete', method: 'post', data: {hash: item}}).send();
});
@@ -208,7 +208,7 @@ initializeWindows = function() {
if (h.length) {
new MochaUI.Window({
id: 'confirmDeletionPage',
title: "_(Deletion confirmation - qBittorrent)",
title: "QBT_TR(Deletion confirmation - qBittorrent)QBT_TR",
loadMethod: 'iframe',
contentURL: 'confirmdeletion.html?hashes=' + h.join(','),
scrollbars: false,
@@ -350,7 +350,7 @@ initializeWindows = function() {
new Request({
url: 'command/shutdown',
onSuccess: function() {
document.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>_(qBittorrent has been shutdown.)</title><style type=\"text/css\">body { text-align: center; }</style></head><body><h1>_(qBittorrent has been shutdown.)</h1></body></html>");
document.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>QBT_TR(qBittorrent has been shutdown.)QBT_TR</title><style type=\"text/css\">body { text-align: center; }</style></head><body><h1>QBT_TR(qBittorrent has been shutdown.)QBT_TR</h1></body></html>");
stop();
}
}).send();

View File

@@ -148,19 +148,19 @@ var createPriorityCombo = function(id, selected_prio) {
});
var opt = new Element("option");
opt.set('value', '1')
opt.set('html', "_(Normal)");
opt.set('html', "QBT_TR(Normal)QBT_TR");
if (selected_prio <= 1)
opt.setAttribute('selected', '');
opt.injectInside(select);
opt = new Element("option");
opt.set('value', '2')
opt.set('html', "_(High)");
opt.set('html', "QBT_TR(High)QBT_TR");
if (selected_prio == 2)
opt.setAttribute('selected', '');
opt.injectInside(select);
opt = new Element("option");
opt.set('value', '7')
opt.set('html', "_(Maximum)");
opt.set('html', "QBT_TR(Maximum)QBT_TR");
if (selected_prio == 7)
opt.setAttribute('selected', '');
opt.injectInside(select);
@@ -295,7 +295,7 @@ var loadTorrentFilesData = function() {
noCache: true,
method: 'get',
onFailure: function() {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR');
clearTimeout(loadTorrentFilesDataTimer);
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(10000);
},

View File

@@ -35,7 +35,7 @@ var loadTorrentData = function() {
noCache: true,
method: 'get',
onFailure: function() {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR');
clearTimeout(loadTorrentDataTimer);
loadTorrentDataTimer = loadTorrentData.delay(10000);
},
@@ -46,7 +46,7 @@ var loadTorrentData = function() {
// Update Torrent data
$('save_path').set('html', data.save_path);
temp = data.creation_date;
var timestamp = "_(Unknown)";
var timestamp = "QBT_TR(Unknown)QBT_TR";
if (temp != -1)
timestamp = new Date(data.creation_date * 1000).toISOString();
$('creation_date').set('html', timestamp);
@@ -54,10 +54,10 @@ var loadTorrentData = function() {
$('comment').set('html', data.comment);
$('total_uploaded').set('html', friendlyUnit(data.total_uploaded) +
" (" + friendlyUnit(data.total_uploaded_session) +
" _(this session)" + ")");
" QBT_TR(this session)QBT_TR" + ")");
$('total_downloaded').set('html', friendlyUnit(data.total_downloaded) +
" (" + friendlyUnit(data.total_downloaded_session) +
" _(this session)" + ")");
" QBT_TR(this session)QBT_TR" + ")");
$('total_wasted').set('html', data.total_wasted);
temp = data.up_limit;
$('up_limit').set('html', temp == -1 ? "∞" : temp);
@@ -65,9 +65,9 @@ var loadTorrentData = function() {
$('dl_limit').set('html', temp == -1 ? "∞" : temp);
temp = friendlyDuration(status.active_time);
if (status.is_seed)
temp += " (" + "_(Seeded for %1)".replace("%1", status.seeding_time) + ")";
temp += " (" + "QBT_TR(Seeded for %1)QBT_TR".replace("%1", status.seeding_time) + ")";
$('time_elapsed').set('html', temp);
temp = data.nb_connections + " (" + "_(%1 max)".replace("%1", status.nb_connections_limit) + ")";
temp = data.nb_connections + " (" + "QBT_TR(%1 max)QBT_TR".replace("%1", status.nb_connections_limit) + ")";
$('nb_connections').set('html', temp);
$('share_ratio').set('html', data.share_ratio.toFixed(2));
}

View File

@@ -75,7 +75,7 @@ var loadTrackersData = function() {
noCache: true,
method: 'get',
onFailure: function() {
$('error_div').set('html', '_(qBittorrent client is not reachable)');
$('error_div').set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR');
clearTimeout(loadTrackersDataTimer);
loadTrackersDataTimer = loadTrackersData.delay(20000);
},
@@ -115,7 +115,7 @@ $('addTrackersPlus').addEvent('click', function addTrackerDlg() {
if (current_hash.length == 0) return;
new MochaUI.Window({
id: 'trackersPage',
title: "_(Trackers addition dialog)",
title: "QBT_TR(Trackers addition dialog)QBT_TR",
loadMethod: 'iframe',
contentURL: 'addtrackers.html?hash=' + current_hash,
scrollbars: true,