From 1aa70bedb7ba528c086e410e20e1b7544664bdef Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sat, 25 Jan 2014 22:29:15 +0400 Subject: [PATCH 1/2] Improve HttpConnection::translateDocument(). --- src/webui/httpconnection.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index f3e7514e3..93c4e23de 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -150,35 +150,37 @@ void HttpConnection::translateDocument(QString& data) { "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel", "PropTabBar", "TorrentModel", - "downloadFromURL"}; + "downloadFromURL", "misc"}; + const size_t context_count = sizeof(contexts)/sizeof(contexts[0]); int i = 0; - bool found; + bool found = true; - do { - found = false; + const QString locale = Preferences().getLocale(); + bool isTranslationNeeded = !locale.startsWith("en") || locale.startsWith("en_AU") || locale.startsWith("en_GB"); + while(i < data.size() && found) { i = regex.indexIn(data, i); if (i >= 0) { //qDebug("Found translatable string: %s", regex.cap(1).toUtf8().data()); QByteArray word = regex.cap(1).toUtf8(); QString translation = word; - bool isTranslationNeeded = !Preferences().getLocale().startsWith("en"); if (isTranslationNeeded) { int context_index = 0; - do { + while(context_index < context_count && translation == word) { translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); ++context_index; - } while(translation == word && context_index < 15); + } } // Remove keyboard shortcuts translation.replace(mnemonic, ""); data.replace(i, regex.matchedLength(), translation); i += translation.length(); - found = true; + } else { + found = false; // no more translatable strings } - } while(found && i < data.size()); + } } void HttpConnection::respond() { From 7fce5ab26826645fd9b377c8488ee8a2a0a214f7 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sat, 25 Jan 2014 22:30:22 +0400 Subject: [PATCH 2/2] Fix sorting by size in WebUI when non-default locale used. --- src/webui/scripts/dynamicTable.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/webui/scripts/dynamicTable.js b/src/webui/scripts/dynamicTable.js index 111a1f7a7..46b4eb38b 100644 --- a/src/webui/scripts/dynamicTable.js +++ b/src/webui/scripts/dynamicTable.js @@ -80,13 +80,15 @@ var dynamicTable = new Class ({ var sizeStrToFloat = function(mystr) { var val1 = mystr.split(' '); var val1num = val1[0].toFloat() - var unit = val1[1].capitalize(); - switch(unit[0]) { - case 'G': + var unit = val1[1]; + switch(unit) { + case '_(TiB)': + return val1num*1099511627776; + case '_(GiB)': return val1num*1073741824; - case 'M': + case '_(MiB)': return val1num*1048576; - case 'K': + case '_(KiB)': return val1num*1024; default: return val1num;