Skip to content

Commit

Permalink
Merge branch 'fix/#231' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Oct 10, 2023
2 parents fe207a3 + 4b85215 commit c22977e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions mayo.pro
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ OTHER_FILES += \
images/credits.txt \
scripts/bump-version.rb \

# Embed qtbase_*.qm files as a resource
qtBaseQmRes.files = \
$$[QT_INSTALL_TRANSLATIONS]/qtbase_en.qm \
$$[QT_INSTALL_TRANSLATIONS]/qtbase_fr.qm
qtBaseQmRes.base = $$[QT_INSTALL_TRANSLATIONS]
qtBaseQmRes.prefix = "/i18n"
RESOURCES += qtBaseQmRes

# Optional developer-specific QMake pri file for environment related settings
exists($$PWD/env.pri) {
include($$PWD/env.pri)
Expand Down
16 changes: 10 additions & 6 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,16 @@ static int runApp(QCoreApplication* qtApp)
appModule->settings()->setStorage(std::make_unique<QSettingsStorage>());
{
// Load translation files
const QString qmFilePath = QString(":/i18n/mayo_%1.qm").arg(appModule->languageCode());
auto translator = new QTranslator(qtApp);
if (translator->load(qmFilePath))
qtApp->installTranslator(translator);
else
qWarning() << Main::tr("Failed to load translation file [path=%1]").arg(qmFilePath);
auto fnLoadQmFile = [=](const QString& qmFilePath) {
auto translator = new QTranslator(qtApp);
if (translator->load(qmFilePath))
qtApp->installTranslator(translator);
else
qWarning() << Main::tr("Failed to load translation file [path=%1]").arg(qmFilePath);
};
const QString appLangCode = appModule->languageCode();
fnLoadQmFile(QString(":/i18n/mayo_%1.qm").arg(appLangCode));
fnLoadQmFile(QString(":/i18n/qtbase_%1.qm").arg(appLangCode));
}

// Initialize Base application
Expand Down

0 comments on commit c22977e

Please sign in to comment.