Skip to content

Commit

Permalink
feat(gui): ship qtbase translations for various qt-defined text
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Jan 7, 2025
1 parent 4c1db24 commit 931e8d1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
${{env.BUILD_DIR}}/LICENSE
${{env.BUILD_DIR}}/vpkedit.exe
${{env.BUILD_DIR}}/*.dll
${{env.BUILD_DIR}}/i18n/*.qm
${{env.BUILD_DIR}}/imageformats/*.dll
${{env.BUILD_DIR}}/platforms/*.dll
${{env.BUILD_DIR}}/styles/*.dll
Expand Down Expand Up @@ -168,6 +169,7 @@ jobs:
${{env.BUILD_DIR}}/LICENSE
${{env.BUILD_DIR}}/vpkedit.exe
${{env.BUILD_DIR}}/*.dll
${{env.BUILD_DIR}}/i18n/*.qm
${{env.BUILD_DIR}}/imageformats/*.dll
${{env.BUILD_DIR}}/platforms/*.dll
${{env.BUILD_DIR}}/styles/*.dll
Expand Down Expand Up @@ -297,6 +299,7 @@ jobs:
${{env.BUILD_DIR}}/vpkedit
${{env.BUILD_DIR}}/*.so*
${{env.BUILD_DIR}}/egldeviceintegrations/*.so*
${{env.BUILD_DIR}}/i18n/*.qm
${{env.BUILD_DIR}}/imageformats/*.so*
${{env.BUILD_DIR}}/platforminputcontexts/*.so*
${{env.BUILD_DIR}}/platforms/*.so*
Expand Down
6 changes: 5 additions & 1 deletion src/gui/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ int main(int argc, char** argv) {
}
Options::setupOptions(*options);

QTranslator translator;
const auto languageOverride = Options::get<QString>(OPT_LANGUAGE_OVERRIDE);
const auto locale = languageOverride.isEmpty() ? QLocale() : QLocale(languageOverride);
QTranslator translatorQtBase;
if (translatorQtBase.load(locale, "qtbase", "_", "i18n")) {
QCoreApplication::installTranslator(&translatorQtBase);
}
QTranslator translator;
if (translator.load(locale, PROJECT_NAME.data(), "_", ":/i18n")) {
QCoreApplication::installTranslator(&translator);
}
Expand Down
12 changes: 12 additions & 0 deletions src/gui/_gui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ if(WIN32)

configure_file("${QT_BASEDIR}/plugins/tls/qcertonlybackend${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/tls/qcertonlybackend${QT_LIB_SUFFIX}.dll" COPYONLY)
configure_file("${QT_BASEDIR}/plugins/tls/qschannelbackend${QT_LIB_SUFFIX}.dll" "${CMAKE_BINARY_DIR}/tls/qschannelbackend${QT_LIB_SUFFIX}.dll" COPYONLY)

# Copy translations
file(GLOB ${PROJECT_NAME}_QTBASE_TRANSLATIONS "${QT_BASEDIR}/translations/qtbase_*.qm")
foreach(${PROJECT_NAME}_QTBASE_TRANSLATION IN LISTS ${PROJECT_NAME}_QTBASE_TRANSLATIONS)
file(COPY "${${PROJECT_NAME}_QTBASE_TRANSLATION}" DESTINATION "${CMAKE_BINARY_DIR}/i18n")
endforeach()
elseif(UNIX AND DEFINED QT_BASEDIR)
configure_file("${QT_BASEDIR}/lib/libQt6Core.so.6" "${CMAKE_BINARY_DIR}/libQt6Core.so.6" COPYONLY)
configure_file("${QT_BASEDIR}/lib/libQt6Gui.so.6" "${CMAKE_BINARY_DIR}/libQt6Gui.so.6" COPYONLY)
Expand Down Expand Up @@ -221,4 +227,10 @@ elseif(UNIX AND DEFINED QT_BASEDIR)
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_WAYLANDGRAPHICSINTEGRATIONCLIENT} DESTINATION "${CMAKE_BINARY_DIR}/wayland-graphics-integration-client")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_WAYLANDSHELLINTEGRATION} DESTINATION "${CMAKE_BINARY_DIR}/wayland-shell-integration")
file(COPY ${${PROJECT_NAME}_QT_PLUGINS_XCBGLINTEGRATIONS} DESTINATION "${CMAKE_BINARY_DIR}/xcbglintegrations")

# Copy translations
file(GLOB ${PROJECT_NAME}_QTBASE_TRANSLATIONS "${QT_BASEDIR}/translations/qtbase_*.qm")
file(COPY ${PROJECT_NAME}_QTBASE_TRANSLATIONS DESTINATION "${CMAKE_BINARY_DIR}/i18n")
else()
set(${PROJECT_NAME}_QTBASE_TRANSLATIONS "")
endif()
3 changes: 3 additions & 0 deletions src/installer/_installer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ install(FILES
"${CMAKE_CURRENT_LIST_DIR}/.nonportable"
DESTINATION .)

install(FILES "${${PROJECT_NAME}_QTBASE_TRANSLATIONS}"
DESTINATION i18n)

if(WIN32)
install(IMPORTED_RUNTIME_ARTIFACTS
Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Svg
Expand Down

0 comments on commit 931e8d1

Please sign in to comment.