From f961fd6a7cbb55967e77211e4fa8b5f1d83bab4e Mon Sep 17 00:00:00 2001 From: buinsky Date: Fri, 8 Jan 2016 13:07:35 +0300 Subject: [PATCH] WebUI: Repair translation --- src/webui/abstractwebapplication.cpp | 25 +++++++++---- src/webui/extra_translations.h | 36 +++++++++++++++---- src/webui/www/private/index.html | 2 +- src/webui/www/public/filters.html | 2 +- src/webui/www/public/preferences_content.html | 4 +-- src/webui/www/public/scripts/client.js | 4 +-- src/webui/www/public/scripts/dynamicTable.js | 4 +-- 7 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/webui/abstractwebapplication.cpp b/src/webui/abstractwebapplication.cpp index cd2e70794..131dd2ee3 100644 --- a/src/webui/abstractwebapplication.cpp +++ b/src/webui/abstractwebapplication.cpp @@ -234,14 +234,15 @@ QString AbstractWebApplication::generateSid() void AbstractWebApplication::translateDocument(QString& data) { - const QRegExp regex("QBT_TR\\((([^\\)]|\\)(?!QBT_TR))+)\\)QBT_TR"); + const QRegExp regex("QBT_TR\\((([^\\)]|\\)(?!QBT_TR))+)\\)QBT_TR(\\[CONTEXT=([a-zA-Z_][a-zA-Z0-9_]*)\\])?"); const QRegExp mnemonic("\\(?&([a-zA-Z]?\\))?"); const std::string contexts[] = { "TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel", "PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc", - "StatusBar", "AboutDlg", "about", "PeerListWidget", "StatusFiltersWidget" + "StatusBar", "AboutDlg", "about", "PeerListWidget", "StatusFiltersWidget", + "LabelFiltersList" }; const size_t context_count = sizeof(contexts) / sizeof(contexts[0]); int i = 0; @@ -258,14 +259,24 @@ void AbstractWebApplication::translateDocument(QString& data) QString translation = word; if (isTranslationNeeded) { - size_t context_index = 0; - while ((context_index < context_count) && (translation == word)) { + QString context = regex.cap(4); + if (context.length() > 0) { #ifndef QBT_USES_QT5 - translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); + translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); #else - translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1); + translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, 1); #endif - ++context_index; + } + else { + size_t context_index = 0; + while ((context_index < context_count) && (translation == word)) { +#ifndef QBT_USES_QT5 + translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); +#else + translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1); +#endif + ++context_index; + } } } // Remove keyboard shortcuts diff --git a/src/webui/extra_translations.h b/src/webui/extra_translations.h index 5a76fd53a..695f6c302 100644 --- a/src/webui/extra_translations.h +++ b/src/webui/extra_translations.h @@ -37,6 +37,7 @@ static const char *__TRANSLATIONS__[] = { QT_TRANSLATE_NOOP("HttpServer", "Edit"), QT_TRANSLATE_NOOP("HttpServer", "Help"), QT_TRANSLATE_NOOP("HttpServer", "Logout"), + QT_TRANSLATE_NOOP("HttpServer", "Exit qBittorrent"), QT_TRANSLATE_NOOP("HttpServer", "Download Torrents from their URL or Magnet link"), QT_TRANSLATE_NOOP("HttpServer", "Only one link per line"), QT_TRANSLATE_NOOP("HttpServer", "Upload local torrent"), @@ -83,16 +84,37 @@ static const char *__TRANSLATIONS__[] = { QT_TRANSLATE_NOOP("HttpServer", "Resumed"), QT_TRANSLATE_NOOP("HttpServer", "Paused"), QT_TRANSLATE_NOOP("HttpServer", "Active"), - QT_TRANSLATE_NOOP("HttpServer", "Inactive") - QT_TRANSLATE_NOOP("HttpServer", "Save files to location:") - QT_TRANSLATE_NOOP("HttpServer", "Label:") - QT_TRANSLATE_NOOP("HttpServer", "Cookie:") - QT_TRANSLATE_NOOP("HttpServer", "Type folder here") - QT_TRANSLATE_NOOP("HttpServer", "Other...") + QT_TRANSLATE_NOOP("HttpServer", "Inactive"), + QT_TRANSLATE_NOOP("HttpServer", "Save files to location:"), + QT_TRANSLATE_NOOP("HttpServer", "Label:"), + QT_TRANSLATE_NOOP("HttpServer", "Cookie:"), + QT_TRANSLATE_NOOP("HttpServer", "Type folder here"), + QT_TRANSLATE_NOOP("HttpServer", "Run an external program on torrent completion"), + QT_TRANSLATE_NOOP("HttpServer", "Enable bandwidth management (uTP)"), + QT_TRANSLATE_NOOP("HttpServer", "Apply rate limit to uTP connections"), + QT_TRANSLATE_NOOP("HttpServer", "Alternative Global Rate Limits"), + QT_TRANSLATE_NOOP("HttpServer", "More information"), + QT_TRANSLATE_NOOP("HttpServer", "Information about certificates"), + QT_TRANSLATE_NOOP("HttpServer", "Save Files to"), + QT_TRANSLATE_NOOP("HttpServer", "Watch Folder"), + QT_TRANSLATE_NOOP("HttpServer", "Default Folder") }; static const struct { const char *source; const char *comment; } __COMMENTED_TRANSLATIONS__[] = { - QT_TRANSLATE_NOOP3("HttpServer", "Downloaded", "Is the file downloaded or not?") + QT_TRANSLATE_NOOP3("HttpServer", "Downloaded", "Is the file downloaded or not?"), + QT_TRANSLATE_NOOP3("HttpServer", "from", "from time1 to time2"), + QT_TRANSLATE_NOOP3("HttpServer", "to", "from time1 to time2"), + QT_TRANSLATE_NOOP3("HttpServer", "Other...", "Save Files to: Watch Folder / Default Folder / Other..."), + QT_TRANSLATE_NOOP3("HttpServer", "Every day", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Week days", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Week ends", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Monday", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Tuesday", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Wednesday", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Thursday", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Friday", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Saturday", "Schedule the use of alternative rate limits on ..."), + QT_TRANSLATE_NOOP3("HttpServer", "Sunday", "Schedule the use of alternative rate limits on ...") }; #endif // EXTRA_TRANSLATIONS_H diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index c8d23def7..685e2ca06 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -55,7 +55,7 @@
  • QBT_TR(Decrease Priority)QBT_TRQBT_TR(Decrease Priority)QBT_TR
  • QBT_TR(Minimum Priority)QBT_TRQBT_TR(Minimum Priority)QBT_TR
  • -
  • QBT_TR(Force Recheck)QBT_TRQBT_TR(Force Recheck)QBT_TR
  • +
  • QBT_TR(Force Recheck)QBT_TRQBT_TR(Force recheck)QBT_TR
  • diff --git a/src/webui/www/public/filters.html b/src/webui/www/public/filters.html index e7f43c2e6..fb9ae708d 100644 --- a/src/webui/www/public/filters.html +++ b/src/webui/www/public/filters.html @@ -1,4 +1,4 @@ -QBT_TR(Torrents)QBT_TR +QBT_TR(Status)QBT_TR