Browse Source

Fix missing words in WebUI

This is because Qt translator returns empty string when the translation
is not provided, now we fallback to the original string from source code.

Closes #9868.
adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
b79a231d2e
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 11
      src/webui/webapplication.cpp

11
src/webui/webapplication.cpp

@ -209,12 +209,15 @@ void WebApplication::translateDocument(QString &data)
QRegularExpressionMatch regexMatch; QRegularExpressionMatch regexMatch;
i = data.indexOf(regex, i, &regexMatch); i = data.indexOf(regex, i, &regexMatch);
if (i >= 0) { if (i >= 0) {
const QString word = regexMatch.captured(1); const QString sourceText = regexMatch.captured(1);
const QString context = regexMatch.captured(3); const QString context = regexMatch.captured(3);
QString translation = isTranslationNeeded QString translation = sourceText;
? m_translator.translate(context.toUtf8().constData(), word.toUtf8().constData(), nullptr, 1) if (isTranslationNeeded) {
: word; const QString loadedText = m_translator.translate(context.toUtf8().constData(), sourceText.toUtf8().constData(), nullptr, 1);
if (!loadedText.isEmpty())
translation = loadedText;
}
// Use HTML code for quotes to prevent issues with JS // Use HTML code for quotes to prevent issues with JS
translation.replace('\'', "'"); translation.replace('\'', "'");

Loading…
Cancel
Save