CI/Windows: bundle Qt's own translations (qtbase) as lang/qt_XX.qm

windeployqt runs with --no-translations, so standard buttons (OK/Cancel)
and dialogs stayed in English. Copy each qtbase_XX.qm from the MSYS2 Qt
translations into files/lang/qt_XX.qm, where QETApp::setLanguage() looks,
with aliases for QET languages Qt only ships with a region (pt, zh).
This commit is contained in:
Laurent Trinques
2026-09-11 11:40:10 +02:00
parent e982778526
commit 4b675dda1b
+35
View File
@@ -248,6 +248,41 @@ jobs:
exit 1
fi
# Qt's own translations (OK/Cancel buttons, standard dialogs...):
# they come from qtbase_XX.qm, not from QET's .ts, and windeployqt
# runs with --no-translations. QETApp::setLanguage() falls back to
# lang/qt_XX.qm, so copy each qtbase_XX.qm there under that name
# (qtbase_XX.qm is standalone, unlike Qt's qt_XX.qm meta catalogs).
QT_TR_DIR=/ucrt64/share/qt6/translations
if [ ! -d "$QT_TR_DIR" ]; then
QT_TR_DIR=$(cygpath -u "$(/ucrt64/bin/qtpaths6 --query QT_INSTALL_TRANSLATIONS 2>/dev/null)" 2>/dev/null || true)
fi
find "$QT_TR_DIR" -maxdepth 1 -name 'qtbase_*.qm' 2>/dev/null | while read -r f; do
l=$(basename "$f" .qm)
cp "$f" "$FILES/lang/qt_${l#qtbase_}.qm"
done
# QET languages Qt only ships with a region (pt -> pt_PT, zh -> zh_CN):
# QTranslator only shortens codes (fr_FR -> fr), it never extends them.
for q in $TS_LISTED; do
l=${q#qet_}
if [ ! -e "$FILES/lang/qt_$l.qm" ]; then
if [ -e "$QT_TR_DIR/qtbase_${l}_${l^^}.qm" ]; then
alt="$QT_TR_DIR/qtbase_${l}_${l^^}.qm"
else
alt=$(find "$QT_TR_DIR" -maxdepth 1 -name "qtbase_${l}_*.qm" 2>/dev/null | LC_ALL=C sort | head -1 || true)
fi
if [ -n "$alt" ]; then
cp "$alt" "$FILES/lang/qt_$l.qm"
fi
fi
done
QT_QM_COUNT=$(find "$FILES/lang" -maxdepth 1 -name 'qt_*.qm' | wc -l)
echo "=== $QT_QM_COUNT Qt translation files (qt_*.qm) copied from $QT_TR_DIR ==="
if [ "$QT_QM_COUNT" -eq 0 ]; then
echo "ERROR: no qtbase_*.qm found in '$QT_TR_DIR' (mingw-w64-ucrt-x86_64-qt6-translations installed?)"
exit 1
fi
for f in LICENSE ChangeLog CREDIT README ELEMENTS.LICENSE; do
cp "$GITHUB_WORKSPACE/$f" "$FILES/$f" 2>/dev/null || true
done