From 484ce3f737e376adf611ff495c2e7a977397b8da Mon Sep 17 00:00:00 2001 From: David Helkowski Date: Thu, 22 Jan 2026 14:48:03 +0900 Subject: [PATCH] Add language defaults for first-run experience and introduce Qt tool command wrapper This commit sets default languages to English for the application unless the user specifies a different language, ensuring a consistent first-run experience across different system locales. Additionally, a wrapper for Qt tools is introduced in the CMake configuration for non-Windows platforms to filter out non-actionable output during builds. --- CMakeLists.txt | 7 +++++++ cmake/qt_tool_wrapper.sh | 25 +++++++++++++++++++++++++ src/main.cpp | 7 +++++++ 3 files changed, 39 insertions(+) create mode 100755 cmake/qt_tool_wrapper.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd1f2329..2d3cd1d1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1530,6 +1530,13 @@ endif() if(HAVE_TRANSLATIONS) option(TRANSLATIONS_VERBOSE "Show verbose output while generating .qm translation files" OFF) + # On non-Windows platforms Qt doesn't need a PATH-setup wrapper for tools, but we can + # provide a wrapper to filter non-actionable lrelease noise during normal builds. + if(NOT CMAKE_HOST_WIN32) + set(QT_TOOL_COMMAND_WRAPPER_PATH "${CMAKE_SOURCE_DIR}/cmake/qt_tool_wrapper.sh" + CACHE INTERNAL "Wrapper used when invoking Qt tools from CMake" FORCE + ) + endif() qt_add_lupdate(strawberry_lib TS_FILES "${CMAKE_SOURCE_DIR}/src/translations/strawberry_en_US.ts" OPTIONS -locations none -no-ui-lines -no-obsolete) file(GLOB_RECURSE ts_files ${CMAKE_SOURCE_DIR}/src/translations/*.ts) set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/data") diff --git a/cmake/qt_tool_wrapper.sh b/cmake/qt_tool_wrapper.sh new file mode 100755 index 000000000..296f384b5 --- /dev/null +++ b/cmake/qt_tool_wrapper.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +tool="${1:-}" +shift || true + +if [[ -z "$tool" ]]; then + echo "qt_tool_wrapper.sh: missing tool argument" >&2 + exit 2 +fi + +base="$(basename "$tool")" + +# Qt LinguistTools (lrelease) prints some noisy informational lines to stderr that +# are not actionable during normal builds (e.g. "Removed plural forms..."). +# We filter only those specific messages. +if [[ "$base" == "lrelease" ]]; then + "$tool" "$@" 2>&1 | sed \ + -e '/^Removed plural forms as the target language has less forms\.$/d' \ + -e '/^If this sounds wrong, possibly the target language is not set or recognized\.$/d' + exit "${PIPESTATUS[0]}" +fi + +exec "$tool" "$@" + diff --git a/src/main.cpp b/src/main.cpp index 9b20fbd7f..754979e16 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -283,6 +283,13 @@ int main(int argc, char *argv[]) { } } + // Default to English unless the user explicitly selected a language (CLI or settings). + // This makes the first-run experience deterministic across system locales. + if (languages.isEmpty()) { + languages << u"en_US"_s; + languages << u"en"_s; + } + // Use system UI languages if (languages.isEmpty()) { # if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)