Skip to content

Commit

Permalink
Close #311: 2nd Fixup for a548227: install QT translation files again
Browse files Browse the repository at this point in the history
The QT provided QM files in QM_FILES got overwritten by the
invokation of the translation function.
Put them into a different variable.

And their name is qtbase_XX.qm, not qt_XX.qm

This fix also translates the "Finder Menu"
  • Loading branch information
chris2511 committed Aug 24, 2024
1 parent 0212113 commit 862e2b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ foreach(lang ${XCA_LANGUAGES})
list(APPEND LANG_COMPREFS " <ComponentRef Id=\"Ci18n.${lang}\"/>\n")
set(LANG_COMPS " <Component Id=\"Ci18n.${lang}\" Guid=\"${GUID}\">
<File Id=\"xca_${lang}.qm\" Source=\"${D}/xca_${lang}.qm\" KeyPath=\"yes\"/>\n")
if(EXISTS ${_qt_bin_dir}/../translations/qt_${lang}.qm)
list(APPEND QM_FILES ${_qt_bin_dir}/../translations/qt_${lang}.qm)
string(APPEND LANG_COMPS " <File Id=\"qt_${lang}.qm\" Source=\"${_qt_bin_dir}/../translations/qt_${lang}.qm\"/>\n")
if(EXISTS ${_qt_bin_dir}/../translations/qtbase_${lang}.qm)
list(APPEND QT_QM_FILES ${_qt_bin_dir}/../translations/qtbase_${lang}.qm)
string(APPEND LANG_COMPS " <File Id=\"qtbase_${lang}.qm\" Source=\"${_qt_bin_dir}/../translations/qtbase_${lang}.qm\"/>\n")
endif()
string(APPEND LANG_COMPS " </Component>\n")
list(APPEND LANG_ALLCOMPS ${LANG_COMPS})
Expand All @@ -40,15 +40,15 @@ else()
)
add_custom_target(trans DEPENDS xca_lupdate "${D}/xca.pot")
endif()
list(APPEND APP_RESOURCES ${QM_FILES})
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${QM_FILES})
list(APPEND APP_RESOURCES ${QM_FILES} ${QT_QM_FILES})
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${QM_FILES} ${QT_QM_FILES})

if (UNIX AND NOT APPLE)
install(FILES ${QM_FILES}
DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/i18n
)
elseif(WIN32)
install(FILES ${QM_FILES}
install(FILES ${QM_FILES} ${QT_QM_FILES}
DESTINATION ${RUNTIME_DEST}/i18n
)
endif()
Expand Down
5 changes: 3 additions & 2 deletions widgets/XcaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ void XcaApplication::setupLanguage(const QLocale &lang)
#endif
};

qDebug() << "Setup language: " << lang;
for (const QString &dir : dirs) {
if (qtTr->load(lang, "qt", dir)) {
qDebug() << "Search QT translations for:" << lang << "in" << lang;
if (qtTr->load(lang, "qtbase", dir)) {
qDebug() << "Fount QT translations for:" << lang << "in" << lang;
break;
}
}
Expand Down
3 changes: 1 addition & 2 deletions widgets/XcaApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class XcaTranslator : public QTranslator
bool load(const QLocale &locale, const QString &filename,
const QString &dir)
{
return QTranslator::load(QString("%1_%2").arg(filename)
.arg(locale.name()), dir);
return QTranslator::load(locale, filename, "_", dir, ".qm");
}
};

Expand Down

0 comments on commit 862e2b4

Please sign in to comment.