[graphics/krita] /: Add a mechanism to fetch translations when building Krita
Halla Rempt
null at kde.org
Wed Feb 24 15:12:59 GMT 2021
Git commit aeb7c53b1a63cf2f86b8b06cd654942804a6e871 by Halla Rempt.
Committed on 24/02/2021 at 15:12.
Pushed by rempt into branch 'master'.
Add a mechanism to fetch translations when building Krita
This adds an option FETCH_TRANSLATIONS, which is (for now) off by
default. If it's enabled, and there is no po folder, a python
script will fetch all translations for Krita. If you want to update
the translations later, all you need to do is rm the po folder.
The scripts used to build Krita on the binary factory now have
FETCH_TRANSLATIONS=ON, so our nightlies have translations as well.
I would recommend everyone to regularly get translations, so we can
test krita's translation problems.
CCMAIL:kimageshop at kde.org
(cherry picked from commit b862c23c7873ec06a3d791846797213d36a87a26)
M +18 -5 CMakeLists.txt
A +53 -0 build-tools/fetch_translations.py
M +1 -0 build-tools/windows/build.cmd
M +1 -0 packaging/linux/appimage/build-krita.sh
M +1 -0 packaging/macos/osxbuild.sh
https://invent.kde.org/graphics/krita/commit/aeb7c53b1a63cf2f86b8b06cd654942804a6e871
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57eb727d86..8023c3880c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -201,6 +201,8 @@ option(ENABLE_UPDATERS "Enable updaters/update notifications" ON)
configure_file(config-updaters.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-updaters.h)
add_feature_info("Enable updaters" ENABLE_UPDATERS "Enable updaters/update notifications.")
+option(FETCH_TRANSLATIONS "Fetch all translations." OFF)
+
# Branding. Available options: default, Beta, Plus, Next. Can be set from command line
if (NOT DEFINED BRANDING)
set(BRANDING "default")
@@ -949,7 +951,7 @@ configure_file(config-ocio.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ocio.h )
check_function_exists(powf HAVE_POWF)
configure_file(config-powf.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-powf.h)
-if(WIN32)
+if (WIN32)
include(${CMAKE_CURRENT_LIST_DIR}/packaging/windows/installer/ConfigureInstallerNsis.cmake)
endif()
@@ -960,11 +962,22 @@ endforeach()
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/po OR EXISTS ${CMAKE_CURRENT_BINARY_DIR}/po )
- find_package(KF5I18n CONFIG REQUIRED)
- ki18n_install(po)
+# Simple command calling the python script
+add_custom_target( get_translations
+ COMMAND python3 ${CMAKE_SOURCE_DIR}/build-tools/fetch_translations.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+)
+
+if (FETCH_TRANSLATIONS AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/po)
+ add_dependencies(krita get_translations)
+endif()
+
+if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/po)
+ find_package(KF5I18n CONFIG REQUIRED)
+ ki18n_install(po)
endif()
+
if (ANDROID)
# ECM passes this to Qt, which was already capable of detecting it..
set (ANDROID_SDK_COMPILE_API "29")
@@ -985,7 +998,7 @@ if (ANDROID)
endif()
endif()
-if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET "create-apk")
+if (DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET "create-apk")
set (_CMAKE_ANDROID_DIR "${ECM_DIR}/../toolchain")
list(LENGTH QTANDROID_EXPORTED_TARGET targetsCount)
include(${_CMAKE_ANDROID_DIR}/ECMAndroidDeployQt.cmake)
diff --git a/build-tools/fetch_translations.py b/build-tools/fetch_translations.py
new file mode 100644
index 0000000000..f8203c6633
--- /dev/null
+++ b/build-tools/fetch_translations.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python3
+
+
+
+stable_url = "svn://anonsvn.kde.org/home/kde/branches/stable/l10n-kf5/"
+unstable_url = "svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5/"
+krita_location = "messages/krita"
+
+# switch these between the stable and unstable krita branch
+url = unstable_url
+#url = stable_url
+
+print (url);
+
+# construct the url and get the subdirs file
+svn_command = url + "subdirs"
+
+import os
+os.makedirs("po", 0o777, True)
+os.chdir("po")
+
+import subprocess
+subdirs = subprocess.run(["svn", "cat", svn_command], stdout=subprocess.PIPE)
+for subdir in subdirs.stdout.decode('utf-8').split('\n'):
+ po_url = url + '/' + subdir + '/' + krita_location + "/krita.po"
+
+ res = subprocess.run(["svn", "cat", po_url], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ po_contents = res.stdout.decode('utf-8')
+ if (len(po_contents) == 0):
+ print ("empty pofile for", subdir, " -- continuing.")
+ continue
+
+ import os
+ import shutil
+ try:
+ shutil.rmtree(subdir)
+ except:
+ pass
+
+ try:
+ os.mkdir(subdir)
+ except:
+ pass
+
+ pofile = subdir + "/krita.po"
+
+ print("writing", len(po_contents), "bytes to", pofile)
+
+ f = open(pofile, 'w')
+ f.write(po_contents)
+ f.close()
+
diff --git a/build-tools/windows/build.cmd b/build-tools/windows/build.cmd
index d4dcec83e5..f050d671be 100644
--- a/build-tools/windows/build.cmd
+++ b/build-tools/windows/build.cmd
@@ -787,6 +787,7 @@ set CMDLINE_CMAKE_KRITA="%CMAKE_EXE%" "%KRITA_SRC_DIR%\." ^
-DFOUNDATION_BUILD=ON ^
-DUSE_QT_TABLET_WINDOWS=ON ^
-DHIDE_SAFE_ASSERTS=ON ^
+ -DFETCH_TRANSLATIONS=ON^
-Wno-dev ^
-G "MinGW Makefiles" ^
-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%
diff --git a/packaging/linux/appimage/build-krita.sh b/packaging/linux/appimage/build-krita.sh
index aa327a3089..6ec18db746 100755
--- a/packaging/linux/appimage/build-krita.sh
+++ b/packaging/linux/appimage/build-krita.sh
@@ -78,6 +78,7 @@ cmake $KRITA_SOURCES \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DFOUNDATION_BUILD=1 \
-DHIDE_SAFE_ASSERTS=ON \
+ -DFETCH_TRANSLATIONS=ON \
-DBUILD_TESTING=FALSE \
-DPYQT_SIP_DIR_OVERRIDE=$DEPS_INSTALL_PREFIX/share/sip/ \
-DHAVE_MEMORY_LEAK_TRACKER=FALSE \
diff --git a/packaging/macos/osxbuild.sh b/packaging/macos/osxbuild.sh
index 3648c4a1e8..a12d75dc0f 100755
--- a/packaging/macos/osxbuild.sh
+++ b/packaging/macos/osxbuild.sh
@@ -428,6 +428,7 @@ build_krita () {
-DDEFINE_NO_DEPRECATED=1 \
-DBUILD_TESTING=${OSXBUILD_TESTING} \
-DHIDE_SAFE_ASSERTS=ON \
+ -DFETCH_TRANSLATIONS=ON \
-DKDE_INSTALL_BUNDLEDIR=${KIS_INSTALL_DIR}/bin \
-DPYQT_SIP_DIR_OVERRIDE=${KIS_INSTALL_DIR}/share/sip/ \
-DCMAKE_BUILD_TYPE=${OSXBUILD_TYPE} \
More information about the kimageshop
mailing list