From e177799adaaa801d48420d825cab1886f8d5a003 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Mon, 1 May 2017 01:45:02 +0300 Subject: [PATCH] [WebUI]Make the context obligatory for translatable strings. Also delete duplicate strings from extra translations. --- src/gui/confirmdeletiondlg.ui | 2 +- src/gui/downloadfromurldlg.ui | 8 +- src/gui/mainwindow.cpp | 3 +- src/gui/optionsdlg.ui | 6 +- src/webui/abstractwebapplication.cpp | 22 +- src/webui/extra_translations.h | 40 +-- src/webui/www/private/index.html | 120 +++---- src/webui/www/private/login.html | 14 +- src/webui/www/public/about.html | 14 +- src/webui/www/public/addtrackers.html | 6 +- src/webui/www/public/confirmdeletion.html | 8 +- src/webui/www/public/download.html | 18 +- src/webui/www/public/downloadlimit.html | 6 +- src/webui/www/public/filters.html | 22 +- src/webui/www/public/newcategory.html | 8 +- src/webui/www/public/preferences.html | 12 +- src/webui/www/public/preferences_content.html | 292 +++++++++--------- src/webui/www/public/properties.html | 10 +- src/webui/www/public/properties_content.html | 70 ++--- src/webui/www/public/scripts/client.js | 34 +- src/webui/www/public/scripts/contextmenu.js | 4 +- src/webui/www/public/scripts/misc.js | 22 +- src/webui/www/public/scripts/mocha-init.js | 30 +- src/webui/www/public/scripts/prop-files.js | 8 +- src/webui/www/public/scripts/prop-general.js | 28 +- src/webui/www/public/scripts/prop-trackers.js | 4 +- src/webui/www/public/scripts/prop-webseeds.js | 2 +- src/webui/www/public/upload.html | 12 +- src/webui/www/public/uploadlimit.html | 6 +- 29 files changed, 393 insertions(+), 438 deletions(-) diff --git a/src/gui/confirmdeletiondlg.ui b/src/gui/confirmdeletiondlg.ui index e52301997..acb55a35a 100644 --- a/src/gui/confirmdeletiondlg.ui +++ b/src/gui/confirmdeletiondlg.ui @@ -17,7 +17,7 @@ - Deletion confirmation - qBittorrent + Deletion confirmation diff --git a/src/gui/downloadfromurldlg.ui b/src/gui/downloadfromurldlg.ui index aa1f763a6..1cf95097f 100644 --- a/src/gui/downloadfromurldlg.ui +++ b/src/gui/downloadfromurldlg.ui @@ -11,7 +11,7 @@ - Download from urls + Download from URLs @@ -33,12 +33,12 @@ - - false - true + + false + diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index a3bf7159a..7af04034c 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1021,7 +1021,8 @@ void MainWindow::closeEvent(QCloseEvent *e) if (!isVisible()) show(); QMessageBox confirmBox(QMessageBox::Question, tr("Exiting qBittorrent"), - tr("Some files are currently transferring.\nAre you sure you want to quit qBittorrent?"), + // Split it because the last sentence is used in the Web UI + tr("Some files are currently transferring.") + "\n" + tr("Are you sure you want to quit qBittorrent?"), QMessageBox::NoButton, this); QPushButton *noBtn = confirmBox.addButton(tr("&No"), QMessageBox::NoRole); confirmBox.addButton(tr("&Yes"), QMessageBox::YesRole); diff --git a/src/gui/optionsdlg.ui b/src/gui/optionsdlg.ui index 80801c0e6..b4989b375 100644 --- a/src/gui/optionsdlg.ui +++ b/src/gui/optionsdlg.ui @@ -679,7 +679,7 @@ 0 0 470 - 994 + 1017 @@ -714,7 +714,7 @@ - + Create subfolder for torrents with multiple files @@ -2754,7 +2754,7 @@ - Enable Web User Interface (Remote control) + Web User Interface (Remote control) true diff --git a/src/webui/abstractwebapplication.cpp b/src/webui/abstractwebapplication.cpp index ef54802da..e529f4137 100644 --- a/src/webui/abstractwebapplication.cpp +++ b/src/webui/abstractwebapplication.cpp @@ -244,17 +244,8 @@ QString AbstractWebApplication::generateSid() void AbstractWebApplication::translateDocument(QString& data) { - const QRegExp regex("QBT_TR\\((([^\\)]|\\)(?!QBT_TR))+)\\)QBT_TR(\\[CONTEXT=([a-zA-Z_][a-zA-Z0-9_]*)\\])?"); + 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", - "CategoryFiltersList", "TransferListDelegate", "AddNewTorrentDialog" - }; - const size_t context_count = sizeof(contexts) / sizeof(contexts[0]); int i = 0; bool found = true; @@ -270,16 +261,7 @@ void AbstractWebApplication::translateDocument(QString& data) QString translation = word; if (isTranslationNeeded) { QString context = regex.cap(4); - if (context.length() > 0) { - translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, 1); - } - else { - size_t context_index = 0; - while ((context_index < context_count) && (translation == word)) { - translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1); - ++context_index; - } - } + translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, 1); } // Remove keyboard shortcuts translation.replace(mnemonic, ""); diff --git a/src/webui/extra_translations.h b/src/webui/extra_translations.h index e49389319..5027a2fa9 100644 --- a/src/webui/extra_translations.h +++ b/src/webui/extra_translations.h @@ -33,16 +33,11 @@ // Additional translations for Web UI static const char *__TRANSLATIONS__[] = { - QT_TRANSLATE_NOOP("HttpServer", "File"), - 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 from URLs"), QT_TRANSLATE_NOOP("HttpServer", "Download Torrents from their URLs or Magnet links"), QT_TRANSLATE_NOOP("HttpServer", "Only one link per line"), QT_TRANSLATE_NOOP("HttpServer", "Upload local torrent"), - QT_TRANSLATE_NOOP("HttpServer", "Download"), QT_TRANSLATE_NOOP("HttpServer", "Are you sure you want to delete the selected torrents from the transfer list?"), QT_TRANSLATE_NOOP("HttpServer", "Global upload rate limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Global download rate limit must be greater than 0 or disabled."), @@ -55,57 +50,34 @@ static const char *__TRANSLATIONS__[] = { QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections per torrent limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of upload slots per torrent limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Unable to save program preferences, qBittorrent is probably unreachable."), - QT_TRANSLATE_NOOP("HttpServer", "Language"), QT_TRANSLATE_NOOP("HttpServer", "The port used for incoming connections must be between 1 and 65535."), QT_TRANSLATE_NOOP("HttpServer", "The port used for the Web UI must be between 1 and 65535."), QT_TRANSLATE_NOOP("HttpServer", "Save"), QT_TRANSLATE_NOOP("HttpServer", "qBittorrent client is not reachable"), - QT_TRANSLATE_NOOP("HttpServer", "HTTP Server"), - QT_TRANSLATE_NOOP("HttpServer", "The following parameters are supported:"), - QT_TRANSLATE_NOOP("HttpServer", "Torrent path"), - QT_TRANSLATE_NOOP("HttpServer", "Torrent name"), QT_TRANSLATE_NOOP("HttpServer", "qBittorrent has been shutdown."), QT_TRANSLATE_NOOP("HttpServer", "Unable to log in, qBittorrent is probably unreachable."), QT_TRANSLATE_NOOP("HttpServer", "Invalid Username or Password."), + QT_TRANSLATE_NOOP("HttpServer", "Username"), QT_TRANSLATE_NOOP("HttpServer", "Password"), QT_TRANSLATE_NOOP("HttpServer", "Login"), - QT_TRANSLATE_NOOP("HttpServer", "Upload Failed!"), QT_TRANSLATE_NOOP("HttpServer", "Original authors"), - QT_TRANSLATE_NOOP("HttpServer", "Upload limit:"), - QT_TRANSLATE_NOOP("HttpServer", "Download limit:"), QT_TRANSLATE_NOOP("HttpServer", "Apply"), QT_TRANSLATE_NOOP("HttpServer", "Add"), - QT_TRANSLATE_NOOP("HttpServer", "All"), - QT_TRANSLATE_NOOP("HttpServer", "Downloading"), - QT_TRANSLATE_NOOP("HttpServer", "Seeding"), - QT_TRANSLATE_NOOP("HttpServer", "Completed"), - 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", "Category:"), 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") + QT_TRANSLATE_NOOP("HttpServer", "IRC: #qbittorrent on Freenode"), + QT_TRANSLATE_NOOP("HttpServer", "Invalid category name:\nPlease do not use any special characters in the category name."), + QT_TRANSLATE_NOOP("HttpServer", "Unknown"), + QT_TRANSLATE_NOOP("HttpServer", "Hard Disk"), + QT_TRANSLATE_NOOP("HttpServer", "Share ratio limit must be between 0 and 9998.") }; 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", "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 ..."), diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 6c84891b0..75794289f 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -3,7 +3,7 @@ - qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR + qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog] @@ -33,106 +33,106 @@
   - QBT_TR(Add Torrent &Link...)QBT_TR - QBT_TR(&Add Torrent File...)QBT_TR - QBT_TR(Delete)QBT_TR - QBT_TR(Resume)QBT_TR - QBT_TR(Pause)QBT_TR + QBT_TR(Add Torrent &Link...)QBT_TR[CONTEXT=MainWindow] + QBT_TR(&Add Torrent File...)QBT_TR[CONTEXT=MainWindow] + QBT_TR(Delete)QBT_TR[CONTEXT=TransferListWidget] + QBT_TR(Resume)QBT_TR[CONTEXT=TransferListWidget] + QBT_TR(Pause)QBT_TR[CONTEXT=TransferListWidget] - QBT_TR(Top Priority)QBT_TR - QBT_TR(Increase Priority)QBT_TR - QBT_TR(Decrease Priority)QBT_TR - QBT_TR(Minimum Priority)QBT_TR + QBT_TR(Top Priority)QBT_TR[CONTEXT=MainWindow] + QBT_TR(Increase Priority)QBT_TR[CONTEXT=MainWindow] + QBT_TR(Decrease Priority)QBT_TR[CONTEXT=MainWindow] + QBT_TR(Minimum Priority)QBT_TR[CONTEXT=MainWindow] - QBT_TR(Options)QBT_TR + QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]
@@ -143,7 +143,7 @@ Connection Status - QBT_TR(Alternative speed limits)QBT_TR + QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow] diff --git a/src/webui/www/private/login.html b/src/webui/www/private/login.html index 252eb3fb6..a073fb980 100644 --- a/src/webui/www/private/login.html +++ b/src/webui/www/private/login.html @@ -3,7 +3,7 @@ - qBittorrent QBT_TR(Web UI)QBT_TR + qBittorrent QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog] @@ -27,10 +27,10 @@

-

QBT_TR(List of trackers to add (one per line):)QBT_TR

+

QBT_TR(List of trackers to add (one per line):)QBT_TR[CONTEXT=TrackersAdditionDlg]


- +
diff --git a/src/webui/www/public/confirmdeletion.html b/src/webui/www/public/confirmdeletion.html index 828f1d54b..4640b03aa 100644 --- a/src/webui/www/public/confirmdeletion.html +++ b/src/webui/www/public/confirmdeletion.html @@ -2,7 +2,7 @@ - QBT_TR(Deletion confirmation - qBittorrent)QBT_TR + QBT_TR(Deletion confirmation - qBittorrent)QBT_TR[CONTEXT=confirmDeletionDlg] @@ -37,10 +37,10 @@
-

  QBT_TR(Are you sure you want to delete the selected torrents from the transfer list?)QBT_TR

-     

+

  QBT_TR(Are you sure you want to delete the selected torrents from the transfer list?)QBT_TR[CONTEXT=HttpServer]

+     

-      +     
diff --git a/src/webui/www/public/download.html b/src/webui/www/public/download.html index e030b6e70..699187d75 100644 --- a/src/webui/www/public/download.html +++ b/src/webui/www/public/download.html @@ -2,7 +2,7 @@ - QBT_TR(Add Torrent Link)QBT_TR + QBT_TR(Add Torrent Links)QBT_TR[CONTEXT=downloadFromURL] @@ -13,33 +13,33 @@

-

QBT_TR(Download Torrents from their URLs or Magnet links)QBT_TR

+

QBT_TR(Download Torrents from their URLs or Magnet links)QBT_TR[CONTEXT=HttpServer]

-

QBT_TR(Only one link per line)QBT_TR

+

QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]

- +
- +
- +
- +
- +
- +
diff --git a/src/webui/www/public/downloadlimit.html b/src/webui/www/public/downloadlimit.html index 43a54d97c..0f8f55d91 100644 --- a/src/webui/www/public/downloadlimit.html +++ b/src/webui/www/public/downloadlimit.html @@ -2,7 +2,7 @@ - QBT_TR(Torrent Download Speed Limiting)QBT_TR + QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget] @@ -12,7 +12,7 @@
-
QBT_TR(Download limit:)QBT_TR QBT_TR(KiB/s)QBT_TR
+
QBT_TR(Download limit:)QBT_TR[CONTEXT=PropertiesWidget] QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimitDialog]
@@ -51,7 +51,7 @@ } } - +
@@ -27,7 +27,7 @@ if (categoryName == null || categoryName == "") return false; if (categoryName.match("^([^\\\\\\/]|[^\\\\\\/]([^\\\\\\/]|\\/(?=[^\\/]))*[^\\\\\\/])$") === null) { - alert("QBT_TR(Invalid category name:\nPlease do not use any special characters in the category name.)QBT_TR"); + alert("QBT_TR(Invalid category name:\nPlease do not use any special characters in the category name.)QBT_TR[CONTEXT=HttpServer]"); return false; } var hashesList = new URI().getData('hashes'); @@ -63,10 +63,10 @@
-

QBT_TR(Category)QBT_TR:

+

QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]:

- +
diff --git a/src/webui/www/public/preferences.html b/src/webui/www/public/preferences.html index 50bed9489..e10e7ad29 100644 --- a/src/webui/www/public/preferences.html +++ b/src/webui/www/public/preferences.html @@ -2,7 +2,7 @@ - QBT_TR(Download from URL)QBT_TR + QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL] @@ -13,11 +13,11 @@ diff --git a/src/webui/www/public/preferences_content.html b/src/webui/www/public/preferences_content.html index 705ce1e90..b67aa8054 100644 --- a/src/webui/www/public/preferences_content.html +++ b/src/webui/www/public/preferences_content.html @@ -1,131 +1,131 @@
- QBT_TR(Hard Disk)QBT_TR + QBT_TR(Hard Disk)QBT_TR[CONTEXT=HttpServer]
- +
- +
-
+
- +

- QBT_TR(Automatically add torrents from:)QBT_TR
+ QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]
- +
QBT_TR(Watched Folder)QBT_TRQBT_TR(Save Files to)QBT_TR
QBT_TR(Monitored Folder)QBT_TR[CONTEXT=ScanFoldersModel]QBT_TR(Override Save Location)QBT_TR[CONTEXT=ScanFoldersModel]
- + Add

-    +   
-    +   
- +
- +
- +
- +
- +
- +
- +
- +
- QBT_TR(Supported parameters (case sensitive):)QBT_TR + QBT_TR(Supported parameters (case sensitive):)QBT_TR[CONTEXT=OptionsDialog]
    -
  • QBT_TR(%N: Torrent name)QBT_TR
  • -
  • QBT_TR(%L: Category)QBT_TR
  • -
  • QBT_TR(%F: Content path (same as root path for multifile torrent))QBT_TR
  • -
  • QBT_TR(%R: Root path (first torrent subdirectory path))QBT_TR
  • -
  • QBT_TR(%D: Save path)QBT_TR
  • -
  • QBT_TR(%C: Number of files)QBT_TR
  • -
  • QBT_TR(%Z: Torrent size (bytes))QBT_TR
  • -
  • QBT_TR(%T: Current tracker)QBT_TR
  • -
  • QBT_TR(%I: Info hash)QBT_TR
  • +
  • QBT_TR(%N: Torrent name)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%L: Category)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%F: Content path (same as root path for multifile torrent))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%R: Root path (first torrent subdirectory path))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%D: Save path)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%C: Number of files)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%Z: Torrent size (bytes))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%T: Current tracker)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%I: Info hash)QBT_TR[CONTEXT=OptionsDialog]
- QBT_TR(Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., "%N"))QBT_TR + QBT_TR(Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., "%N"))QBT_TR[CONTEXT=OptionsDialog]