Browse Source

Merge pull request #4526 from buinsky/WebUI_translation

WebUI: Repair translation
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
ca45d15424
  1. 25
      src/webui/abstractwebapplication.cpp
  2. 36
      src/webui/extra_translations.h
  3. 2
      src/webui/www/private/index.html
  4. 2
      src/webui/www/public/filters.html
  5. 4
      src/webui/www/public/preferences_content.html
  6. 4
      src/webui/www/public/scripts/client.js
  7. 4
      src/webui/www/public/scripts/dynamicTable.js

25
src/webui/abstractwebapplication.cpp

@ -234,14 +234,15 @@ QString AbstractWebApplication::generateSid()
void AbstractWebApplication::translateDocument(QString& data) 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 QRegExp mnemonic("\\(?&([a-zA-Z]?\\))?");
const std::string contexts[] = { const std::string contexts[] = {
"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget",
"HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel",
"options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel", "options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel",
"PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc", "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]); const size_t context_count = sizeof(contexts) / sizeof(contexts[0]);
int i = 0; int i = 0;
@ -258,14 +259,24 @@ void AbstractWebApplication::translateDocument(QString& data)
QString translation = word; QString translation = word;
if (isTranslationNeeded) { if (isTranslationNeeded) {
size_t context_index = 0; QString context = regex.cap(4);
while ((context_index < context_count) && (translation == word)) { if (context.length() > 0) {
#ifndef QBT_USES_QT5 #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 #else
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1); translation = qApp->translate(context.toUtf8().constData(), word.constData(), 0, 1);
#endif #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 // Remove keyboard shortcuts

36
src/webui/extra_translations.h

@ -37,6 +37,7 @@ static const char *__TRANSLATIONS__[] = {
QT_TRANSLATE_NOOP("HttpServer", "Edit"), QT_TRANSLATE_NOOP("HttpServer", "Edit"),
QT_TRANSLATE_NOOP("HttpServer", "Help"), QT_TRANSLATE_NOOP("HttpServer", "Help"),
QT_TRANSLATE_NOOP("HttpServer", "Logout"), 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", "Download Torrents from their URL or Magnet link"),
QT_TRANSLATE_NOOP("HttpServer", "Only one link per line"), QT_TRANSLATE_NOOP("HttpServer", "Only one link per line"),
QT_TRANSLATE_NOOP("HttpServer", "Upload local torrent"), QT_TRANSLATE_NOOP("HttpServer", "Upload local torrent"),
@ -83,16 +84,37 @@ static const char *__TRANSLATIONS__[] = {
QT_TRANSLATE_NOOP("HttpServer", "Resumed"), QT_TRANSLATE_NOOP("HttpServer", "Resumed"),
QT_TRANSLATE_NOOP("HttpServer", "Paused"), QT_TRANSLATE_NOOP("HttpServer", "Paused"),
QT_TRANSLATE_NOOP("HttpServer", "Active"), QT_TRANSLATE_NOOP("HttpServer", "Active"),
QT_TRANSLATE_NOOP("HttpServer", "Inactive") QT_TRANSLATE_NOOP("HttpServer", "Inactive"),
QT_TRANSLATE_NOOP("HttpServer", "Save files to location:") QT_TRANSLATE_NOOP("HttpServer", "Save files to location:"),
QT_TRANSLATE_NOOP("HttpServer", "Label:") QT_TRANSLATE_NOOP("HttpServer", "Label:"),
QT_TRANSLATE_NOOP("HttpServer", "Cookie:") QT_TRANSLATE_NOOP("HttpServer", "Cookie:"),
QT_TRANSLATE_NOOP("HttpServer", "Type folder here") QT_TRANSLATE_NOOP("HttpServer", "Type folder here"),
QT_TRANSLATE_NOOP("HttpServer", "Other...") 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__[] = { 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 #endif // EXTRA_TRANSLATIONS_H

2
src/webui/www/private/index.html

@ -55,7 +55,7 @@
<li><a id="decreasePrioLink"><img class="MyMenuIcon" src="theme/go-down" alt="QBT_TR(Decrease Priority)QBT_TR" width="16" height="16" onload="fixPNG(this)"/>QBT_TR(Decrease Priority)QBT_TR</a></li> <li><a id="decreasePrioLink"><img class="MyMenuIcon" src="theme/go-down" alt="QBT_TR(Decrease Priority)QBT_TR" width="16" height="16" onload="fixPNG(this)"/>QBT_TR(Decrease Priority)QBT_TR</a></li>
<li><a id="bottomPrioLink"><img class="MyMenuIcon" src="theme/go-bottom" alt="QBT_TR(Minimum Priority)QBT_TR" width="16" height="16" onload="fixPNG(this)"/>QBT_TR(Minimum Priority)QBT_TR</a></li> <li><a id="bottomPrioLink"><img class="MyMenuIcon" src="theme/go-bottom" alt="QBT_TR(Minimum Priority)QBT_TR" width="16" height="16" onload="fixPNG(this)"/>QBT_TR(Minimum Priority)QBT_TR</a></li>
</span> </span>
<li class="divider"><a id="recheckLink"><img class="MyMenuIcon" src="theme/document-edit-verify" alt="QBT_TR(Force Recheck)QBT_TR" width="16" height="16" onload="fixPNG(this)"/>QBT_TR(Force Recheck)QBT_TR</a></li> <li class="divider"><a id="recheckLink"><img class="MyMenuIcon" src="theme/document-edit-verify" alt="QBT_TR(Force Recheck)QBT_TR" width="16" height="16" onload="fixPNG(this)"/>QBT_TR(Force recheck)QBT_TR</a></li>
</ul> </ul>
</li> </li>
<li> <li>

2
src/webui/www/public/filters.html

@ -1,4 +1,4 @@
QBT_TR(Torrents)QBT_TR QBT_TR(Status)QBT_TR
<ul class="filterList"> <ul class="filterList">
<li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All (0))QBT_TR</a></li> <li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All (0))QBT_TR</a></li>
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading (0))QBT_TR</a></li> <li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading (0))QBT_TR</a></li>

4
src/webui/www/public/preferences_content.html

@ -272,7 +272,7 @@
<option value="2">QBT_TR(Disable encryption)QBT_TR</option> <option value="2">QBT_TR(Disable encryption)QBT_TR</option>
</select><br/> </select><br/>
<input type="checkbox" id="anonymous_mode_checkbox"/> <input type="checkbox" id="anonymous_mode_checkbox"/>
<label for="anonymous_mode_checkbox">QBT_TR(Enable anonymous mode)QBT_TR (<a target="_blank" href="https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode">More information</a>)</label><br/> <label for="anonymous_mode_checkbox">QBT_TR(Enable anonymous mode)QBT_TR (<a target="_blank" href="https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode">QBT_TR(More information)QBT_TR</a>)</label><br/>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
@ -378,7 +378,7 @@
<label for="ssl_cert_textarea" style="margin-left: 20px;">QBT_TR(Certificate:)QBT_TR</label> <label for="ssl_cert_textarea" style="margin-left: 20px;">QBT_TR(Certificate:)QBT_TR</label>
<textarea id="ssl_cert_textarea" rows="5" cols="70"></textarea> <textarea id="ssl_cert_textarea" rows="5" cols="70"></textarea>
</div> </div>
<div style="padding-left: 10px;"><a target="_blank" href="http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#aboutcerts">Information about certificates</a></div> <div style="padding-left: 10px;"><a target="_blank" href="http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#aboutcerts">QBT_TR(Information about certificates)QBT_TR</a></div>
</fieldset> </fieldset>
</fieldset> </fieldset>

4
src/webui/www/public/scripts/client.js

@ -255,8 +255,8 @@ window.addEvent('load', function () {
if (row['full_data'].label.length === 0) if (row['full_data'].label.length === 0)
unlabelled += 1; unlabelled += 1;
}); });
labelList.appendChild(create_link(LABELS_ALL, 'QBT_TR(All)QBT_TR', all)); labelList.appendChild(create_link(LABELS_ALL, 'QBT_TR(All (0))QBT_TR'.replace(' (0)', ''), all));
labelList.appendChild(create_link(LABELS_UNLABELLED, 'QBT_TR(Unlabeled)QBT_TR', unlabelled)); labelList.appendChild(create_link(LABELS_UNLABELLED, 'QBT_TR(Unlabeled (0))QBT_TR'.replace(' (0)', ''), unlabelled));
var sortedLabels = [] var sortedLabels = []
Object.each(label_list, function(label) { Object.each(label_list, function(label) {

4
src/webui/www/public/scripts/dynamicTable.js

@ -734,8 +734,8 @@ var TorrentPeersTable = new Class({
this.newColumn('progress', 'width: 30px', 'QBT_TR(Progress)QBT_TR'); this.newColumn('progress', 'width: 30px', 'QBT_TR(Progress)QBT_TR');
this.newColumn('dl_speed', 'width: 30px', 'QBT_TR(Down Speed)QBT_TR'); this.newColumn('dl_speed', 'width: 30px', 'QBT_TR(Down Speed)QBT_TR');
this.newColumn('up_speed', 'width: 30px', 'QBT_TR(Up Speed)QBT_TR'); this.newColumn('up_speed', 'width: 30px', 'QBT_TR(Up Speed)QBT_TR');
this.newColumn('downloaded', 'width: 30px', 'QBT_TR(Downloaded)QBT_TR'); this.newColumn('downloaded', 'width: 30px', 'QBT_TR(Downloaded)QBT_TR[CONTEXT=PeerListWidget]');
this.newColumn('uploaded', 'width: 30px', 'QBT_TR(Uploaded)QBT_TR'); this.newColumn('uploaded', 'width: 30px', 'QBT_TR(Uploaded)QBT_TR[CONTEXT=PeerListWidget]');
this.newColumn('connection', 'width: 30px', 'QBT_TR(Connection)QBT_TR'); this.newColumn('connection', 'width: 30px', 'QBT_TR(Connection)QBT_TR');
this.newColumn('flags', 'width: 30px', 'QBT_TR(Flags)QBT_TR'); this.newColumn('flags', 'width: 30px', 'QBT_TR(Flags)QBT_TR');
this.newColumn('relevance', 'min-width: 30px', 'QBT_TR(Relevance)QBT_TR'); this.newColumn('relevance', 'min-width: 30px', 'QBT_TR(Relevance)QBT_TR');

Loading…
Cancel
Save