|
|
@ -150,35 +150,37 @@ void HttpConnection::translateDocument(QString& data) { |
|
|
|
"confirmDeletionDlg", "TrackerList", "TorrentFilesModel", |
|
|
|
"confirmDeletionDlg", "TrackerList", "TorrentFilesModel", |
|
|
|
"options_imp", "Preferences", "TrackersAdditionDlg", |
|
|
|
"options_imp", "Preferences", "TrackersAdditionDlg", |
|
|
|
"ScanFoldersModel", "PropTabBar", "TorrentModel", |
|
|
|
"ScanFoldersModel", "PropTabBar", "TorrentModel", |
|
|
|
"downloadFromURL"}; |
|
|
|
"downloadFromURL", "misc"}; |
|
|
|
|
|
|
|
const size_t context_count = sizeof(contexts)/sizeof(contexts[0]); |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
bool found; |
|
|
|
bool found = true; |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
const QString locale = Preferences().getLocale(); |
|
|
|
found = false; |
|
|
|
bool isTranslationNeeded = !locale.startsWith("en") || locale.startsWith("en_AU") || locale.startsWith("en_GB"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(i < data.size() && found) { |
|
|
|
i = regex.indexIn(data, i); |
|
|
|
i = regex.indexIn(data, i); |
|
|
|
if (i >= 0) { |
|
|
|
if (i >= 0) { |
|
|
|
//qDebug("Found translatable string: %s", regex.cap(1).toUtf8().data());
|
|
|
|
//qDebug("Found translatable string: %s", regex.cap(1).toUtf8().data());
|
|
|
|
QByteArray word = regex.cap(1).toUtf8(); |
|
|
|
QByteArray word = regex.cap(1).toUtf8(); |
|
|
|
|
|
|
|
|
|
|
|
QString translation = word; |
|
|
|
QString translation = word; |
|
|
|
bool isTranslationNeeded = !Preferences().getLocale().startsWith("en"); |
|
|
|
|
|
|
|
if (isTranslationNeeded) { |
|
|
|
if (isTranslationNeeded) { |
|
|
|
int context_index = 0; |
|
|
|
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); |
|
|
|
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); |
|
|
|
++context_index; |
|
|
|
++context_index; |
|
|
|
} while(translation == word && context_index < 15); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Remove keyboard shortcuts
|
|
|
|
// Remove keyboard shortcuts
|
|
|
|
translation.replace(mnemonic, ""); |
|
|
|
translation.replace(mnemonic, ""); |
|
|
|
|
|
|
|
|
|
|
|
data.replace(i, regex.matchedLength(), translation); |
|
|
|
data.replace(i, regex.matchedLength(), translation); |
|
|
|
i += translation.length(); |
|
|
|
i += translation.length(); |
|
|
|
found = true; |
|
|
|
} else { |
|
|
|
|
|
|
|
found = false; // no more translatable strings
|
|
|
|
} |
|
|
|
} |
|
|
|
} while(found && i < data.size()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HttpConnection::respond() { |
|
|
|
void HttpConnection::respond() { |
|
|
|