Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix translations in Qt6-based AppImages

Dmitry Kazakov11b36c4944b4
diff --git a/krita/main.cc b/krita/main.cc
index 5a89efee17..d51002a812 100644
--- a/krita/main.cc
+++ b/krita/main.cc
@@ -644,8 +644,22 @@ if (!qEnvironmentVariableIsEmpty("KRITA_OPENGL_DEBUG")) {
#ifdef Q_OS_ANDROID
KisApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
#endif
- // Enable debugging translations from undeployed apps
+
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ /**
+ * In Qt5 version of Krita we used to patch ki18n to look for translations
+ * in QStandardPaths::AppLocalDataLocation and then manually move them
+ * into this location in the AppImage creation script. It meant that
+ * translations wouldn't work for undeployed builds, e.g. the one in
+ * the docker, where the translations were automatically installed
+ * into the default location, i.e. krita.appdir/usr/share/locale.
+ *
+ * In Qt6 we dropped this patch over ki18n and it now searches
+ * translations in the correct location, i.e.
+ * in QStandardPaths::GenericDataLocation.
+ */
KLocalizedString::addDomainLocaleDir("krita", QDir(root + "share/locale").absolutePath());
+#endif
KLocalizedString::setApplicationDomain("krita");
diff --git a/packaging/linux/appimage/build-image.sh b/packaging/linux/appimage/build-image.sh
index f90e8393b3..74f6413c6f 100755
--- a/packaging/linux/appimage/build-image.sh
+++ b/packaging/linux/appimage/build-image.sh
@@ -32,6 +32,9 @@ export LD_LIBRARY_PATH=$DEPS_INSTALL_PREFIX/lib/:$DEPS_INSTALL_PREFIX/lib/$TRIPL
export PATH=$DEPS_INSTALL_PREFIX/bin/:$PATH
export PKG_CONFIG_PATH=$DEPS_INSTALL_PREFIX/share/pkgconfig/:$DEPS_INSTALL_PREFIX/lib/pkgconfig/:/usr/lib/pkgconfig/:$PKG_CONFIG_PATH
export CMAKE_PREFIX_PATH=$DEPS_INSTALL_PREFIX:$CMAKE_PREFIX_PATH
+
+export QT_VERSION_MAJOR=$(echo $($DEPS_INSTALL_PREFIX/bin/qtpaths --qt-version) | cut -d. -f1)
+
# https://docs.python.org/3.10/using/cmdline.html#envvar-PYTHONHOME
if [ -d $DEPS_INSTALL_PREFIX/sip ] ; then
export PYTHONPATH=$DEPS_INSTALL_PREFIX/sip
@@ -149,13 +152,24 @@ cd $BUILD_PREFIX
#
# Step 0: place the translations where ki18n and Qt look for them
-if [ -d $APPDIR/usr/share/locale ] ; then
- rsync -prul $APPDIR/usr/share/locale $APPDIR/usr/share/krita
- rm -rf $APPDIR/usr/share/locale
+#
+# In Qt5 version of Krita we used to patch ki18n to locate the translations
+# in QStandardPaths::AppLocalDataLocation, hence all the translations had to
+# be moved into the Krita-local directory. In Qt6 we dropped this patch, so
+# all the translations are now searched in QStandardPaths::GenericDataLocation
+
+if [ "$QT_VERSION_MAJOR" = "5" ] ; then
+ if [ -d $APPDIR/usr/share/locale ] ; then
+ rsync -prul $APPDIR/usr/share/locale $APPDIR/usr/share/krita
+ rm -rf $APPDIR/usr/share/locale
+ fi
+ rsync -prul $DEPS_INSTALL_PREFIX/share/locale $APPDIR/usr/share/krita
+else
+ rsync -prul $DEPS_INSTALL_PREFIX/share/locale $APPDIR/usr/share/
fi
# Step 1: Copy over all necessary resources required by dependencies or libraries that are missed by linuxdeployqt
-cp -r $DEPS_INSTALL_PREFIX/share/locale $APPDIR/usr/share/krita
+
if [ -d $DEPS_INSTALL_PREFIX/share/kf5 ]; then
cp -r $DEPS_INSTALL_PREFIX/share/kf5 $APPDIR/usr/share
else