tdf#133788 Missing pieces for Gallery localization

Change-Id: Id11227b4a271351b50c43f6b5a531b47261c6fc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98544
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
(cherry picked from commit 244de1fc0f3f201f56e739401ee3cc52f35deab4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98768
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/Repository.mk b/Repository.mk
index 7e7b805..0ab6322 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -882,6 +882,7 @@ $(eval $(call gb_Helper_register_packages_for_install,ooo,\
	extras_gallmytheme \
	extras_gallroot \
	extras_gallsystem \
	extras_gallsystemstr \
	extras_glade \
	extras_labels \
	$(if $(filter WNT,$(OS)),extras_newfiles) \
diff --git a/extras/CustomTarget_gallsystem.mk b/extras/CustomTarget_gallsystem.mk
new file mode 100644
index 0000000..271c733
--- /dev/null
+++ b/extras/CustomTarget_gallsystem.mk
@@ -0,0 +1,36 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

$(eval $(call gb_CustomTarget_CustomTarget,extras/gallsysstr))

# bullets, fontwork symbolshapes not listed in ulf/not currently enabled for translation
$(eval $(call gb_CustomTarget_register_targets,extras/gallsysstr,\
    $(addsuffix .str,$(filter-out bullets fontwork symbolshapes,$(system_galleries))) \
))

$(eval $(call gb_CustomTarget_ulfex_rule,\
    $(call gb_CustomTarget_get_workdir,extras/gallsysstr)/extras_gallsystem.ulf,\
    $(SRCDIR)/extras/source/gallery/share/gallery_names.ulf,\
    $(foreach lang,$(gb_TRANS_LANGS),\
        $(gb_POLOCATION)/$(lang)/extras/source/gallery/share.po)))

# desktop-translate.py is ugly af/doesn't play nice with make dependencies.
# It expects the target filename to exist and modifies it, so do the hack with own
# temporary dir
$(call gb_CustomTarget_get_workdir,extras/gallsysstr)/%.str : \
                    $(call gb_CustomTarget_get_workdir,extras/gallsysstr)/extras_gallsystem.ulf \
                    $(SRCDIR)/extras/source/gallery/gallery_system/dummy.str \
                    $(call gb_ExternalExecutable_get_dependencies,python) \
                    $(SRCDIR)/solenv/bin/desktop-translate.py
	mkdir -p $(@D)/$* && cp $(SRCDIR)/extras/source/gallery/gallery_system/dummy.str $(@D)/$*/$*.str && \
	$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/solenv/bin/desktop-translate.py \
            --ext "str" --key "name" -d $(@D)/$*/ $(@D)/extras_gallsystem.ulf && \
	mv $(@D)/$*/$*.str $@

# vim: set noet sw=4 ts=4:
diff --git a/extras/Module_extras.mk b/extras/Module_extras.mk
index bb14928..cf7177c 100644
--- a/extras/Module_extras.mk
+++ b/extras/Module_extras.mk
@@ -13,6 +13,7 @@ $(eval $(call gb_Module_add_targets,extras,\
	CustomTarget_autocorr \
	CustomTarget_autotextuser \
	CustomTarget_glade \
	CustomTarget_gallsystem \
	CustomTarget_tplofficorr \
	CustomTarget_tploffimisc \
	CustomTarget_tplpersonal \
@@ -31,6 +32,7 @@ $(eval $(call gb_Module_add_targets,extras,\
	Package_gallmytheme \
	Package_gallroot \
	Package_gallsystem \
	Package_gallsystemstr \
	Package_glade \
	Package_labels \
	$(if $(filter WNT,$(OS)),Package_newfiles) \
diff --git a/extras/Package_gallsystem.mk b/extras/Package_gallsystem.mk
index c17099c..4ff2774 100644
--- a/extras/Package_gallsystem.mk
+++ b/extras/Package_gallsystem.mk
@@ -7,39 +7,14 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

system_galleries := arrows bpmn bullets diagrams flowchart fontwork icons network shapes symbolshapes

$(eval $(call gb_Package_Package,extras_gallsystem,$(SRCDIR)/extras/source/gallery/gallery_system))

$(eval $(call gb_Package_add_files,extras_gallsystem,$(LIBO_SHARE_FOLDER)/gallery,\
	arrows.sdg \
	arrows.sdv \
	arrows.thm \
	bpmn.sdg \
	bpmn.sdv \
	bpmn.thm \
	bullets.sdg \
	bullets.sdv \
	bullets.thm \
	diagrams.sdg \
	diagrams.sdv \
	diagrams.thm \
	flowchart.sdg \
	flowchart.sdv \
	flowchart.thm \
	fontwork.sdg \
	fontwork.sdv \
	fontwork.thm \
	icons.sdg \
	icons.sdv \
	icons.thm \
	network.sdg \
	network.sdv \
	network.thm \
	shapes.sdg \
	shapes.sdv \
	shapes.thm \
	symbolshapes.sdg \
	symbolshapes.sdv \
	symbolshapes.thm \
    $(addsuffix .sdg,$(system_galleries)) \
    $(addsuffix .sdv,$(system_galleries)) \
    $(addsuffix .thm,$(system_galleries)) \
))

# vim: set noet sw=4 ts=4:
diff --git a/extras/Package_gallsystemstr.mk b/extras/Package_gallsystemstr.mk
new file mode 100644
index 0000000..548b5fd
--- /dev/null
+++ b/extras/Package_gallsystemstr.mk
@@ -0,0 +1,18 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

# defining extra package for that is a little hacky - maybe use PackageSet instead?
$(eval $(call gb_Package_Package,extras_gallsystemstr,$(call gb_CustomTarget_get_workdir,extras/gallsysstr)))
$(eval $(call gb_Package_use_customtarget,extras_gallsystemstr,extras/gallsysstr))

$(eval $(call gb_Package_add_files,extras_gallsystemstr,$(LIBO_SHARE_FOLDER)/gallery,\
    $(addsuffix .str,$(filter-out bullets fontwork symbolshapes,$(system_galleries))) \
))

# vim: set noet sw=4 ts=4:
diff --git a/extras/source/gallery/gallery_system/dummy.str b/extras/source/gallery/gallery_system/dummy.str
new file mode 100644
index 0000000..bae770e
--- /dev/null
+++ b/extras/source/gallery/gallery_system/dummy.str
@@ -0,0 +1,2 @@
# Translated by desktop-translate and ulfex
name = "see extras/source/gallery/share/gallery_names.ulf"