summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@qt.io>2020-07-21 11:53:00 +0200
committerTim Jenssen <tim.jenssen@qt.io>2020-07-21 15:37:52 +0000
commitb1fc2cdbb41a3dd6222619a495ac98292458135d (patch)
tree4a020baf68cbed347f3802114de18b21872530b0
parentb45b771581860f26a99950954e5c47e614f36943 (diff)
downloadqt-creator-b1fc2cdbb41a3dd6222619a495ac98292458135d.tar.gz
qmlpreview: fix translation for qml files in subdirectories
Found path was ignored - so the location was wrong Keeping the kind of ugly in findValidI18nDirectoryAsUrl(const QString &locale) for now - to not change too much in that area. Change-Id: I491df1f928868a8d9afbbb7d25c8102bbe9b51a7 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
-rw-r--r--src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp b/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp
index 0fcf6a36b8..69a33cfa58 100644
--- a/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp
+++ b/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp
@@ -76,17 +76,22 @@ void QmlPreviewConnectionManager::createClients()
QUrl QmlPreviewConnectionManager::findValidI18nDirectoryAsUrl(const QString &locale)
{
+ QTC_ASSERT(!m_lastLoadedUrl.isEmpty(), return {};);
+
const QString shortLocale = locale.left(locale.indexOf("_"));
QString path = m_lastLoadedUrl.path();
+ QString foundPath;
while (!path.isEmpty()) {
path = path.left(qMax(0, path.lastIndexOf("/")));
QUrl url = m_lastLoadedUrl;
+
auto tryPath = [&](const QString &postfix) {
url.setPath(path + "/i18n/qml_" + postfix);
bool success = false;
- m_projectFileFinder.findFile(url, &success);
+ foundPath = m_projectFileFinder.findFile(url, &success).first().toString();
+ foundPath = foundPath.left(qMax(0, foundPath.lastIndexOf("/i18n")));
return success;
};
@@ -101,7 +106,10 @@ QUrl QmlPreviewConnectionManager::findValidI18nDirectoryAsUrl(const QString &loc
}
QUrl url = m_lastLoadedUrl;
- url.setPath(path);
+ if (foundPath.isEmpty())
+ url.setPath(path);
+ else
+ url.setPath(foundPath);
return url;
}