From b79a231d2e681ec39cc84cf3d6b994dd4e9d1262 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 23 Nov 2018 23:37:03 +0800 Subject: [PATCH] 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. --- src/webui/webapplication.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index ecc57a294..5af4c5dfb 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -209,12 +209,15 @@ void WebApplication::translateDocument(QString &data) QRegularExpressionMatch regexMatch; i = data.indexOf(regex, i, ®exMatch); if (i >= 0) { - const QString word = regexMatch.captured(1); + const QString sourceText = regexMatch.captured(1); const QString context = regexMatch.captured(3); - QString translation = isTranslationNeeded - ? m_translator.translate(context.toUtf8().constData(), word.toUtf8().constData(), nullptr, 1) - : word; + QString translation = sourceText; + if (isTranslationNeeded) { + 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 translation.replace('\'', "'");