From 071a01a2d6554abf782a29ec23b44e3d60534b89 Mon Sep 17 00:00:00 2001 From: EndrII <EndrIIMail@gmail.com> Date: Sun, 29 May 2022 14:03:56 +0300 Subject: [PATCH] fix load translations on android and ios dvices --- locales.cpp | 13 ++++++++++++- locales.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/locales.cpp b/locales.cpp index 54a876d..b27044c 100644 --- a/locales.cpp +++ b/locales.cpp @@ -21,10 +21,21 @@ using namespace QuasarAppUtils; bool QuasarAppUtils::Locales::findQm(const QString& localePrefix, QFileInfoList &qmFiles) { + if (localePrefix.isEmpty()) + return false; + + qDebug() << "Search for " << localePrefix; + + const auto prefixes = localePrefix.split(QRegExp("[_-]")); + + auto prefixIt = prefixes.begin(); + for (const auto &location: qAsConst(_locations)) { - qmFiles += QDir(location).entryInfoList({"*" + localePrefix + "*.qm"}, QDir::Files); + qmFiles += QDir(location).entryInfoList({"*" + (*prefixIt).toLower() + "*.qm"}, QDir::Files); } + qDebug() << "Found" << qmFiles; + return qmFiles.size(); } diff --git a/locales.h b/locales.h index 8e094ed..b1977dd 100644 --- a/locales.h +++ b/locales.h @@ -33,6 +33,8 @@ namespace QuasarAppUtils { * @code{cpp} * QuasarAppUtils::Locales::init(QLocale::system(), "myPath"); * @endcode + * + * @note All translations qm files should be named with lower case example : en.qm */ class QUASARAPPSHARED_EXPORT Locales : public QObject {