fix load translations on android and ios dvices

This commit is contained in:
Andrei Yankovich 2022-05-29 14:03:56 +03:00
parent 11947d4cde
commit 071a01a2d6
2 changed files with 14 additions and 1 deletions

View File

@ -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();
}

View File

@ -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
{