[gimp-help] build, po-windows-installer: localize the installer strings.



commit b2f9d3582e9a178f6013507de74725e0752ce6d8
Author: Jehan <jehan girinstud io>
Date:   Sun Mar 20 16:29:56 2022 +0100

    build, po-windows-installer: localize the installer strings.
    
    1. Extract the Windows installer custom messages and store them as
       gettext files in the separate po-windows-installer/ folder. Use a
       Makefile.in.in nearly identical to the one on the GIMP repository
       (though a bit different, in particular, it also creates non-existing
       po files because we always need the localized .isl, even if it's
       nearly empty.
    2. Rename help.en.isl as template help.isl.in, which will be used for
       gettext extraction. Then merge the po translations with this template
       to create help.*.isl localized files for each supported language.
    3. Use these localized language files in the InnoSetup script. The
       original (US English) isl file is always used as backup, in case of
       no or incomplete translation.
    
    (cherry picked from commit f508bec75300036677d71488c1a63da544d4c2f4)

 Makefile.am                              |   2 +-
 build/Makefile.am                        |   1 +
 build/windows/Makefile.am                |   1 +
 build/windows/installer/Makefile.am      |   1 +
 build/windows/installer/gimp-help.iss    |   2 +-
 build/windows/installer/lang/Makefile.am |  45 ++++++
 build/windows/installer/lang/help.en.isl |  10 --
 build/windows/installer/lang/help.isl.in |  10 ++
 configure.ac                             |  50 +++++++
 po-windows-installer/Makefile.in.in      | 234 +++++++++++++++++++++++++++++++
 po-windows-installer/POTFILES.in         |   6 +
 po-windows-installer/POTFILES.skip       |   8 ++
 12 files changed, 358 insertions(+), 12 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9512c66e9..c9745eb4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = quickreference m4macros
+SUBDIRS = quickreference m4macros po-windows-installer build
 
 # used for creating the ChangeLog
 LAST_RELEASE_TAG = GIMP_HELP_2_8_2
diff --git a/build/Makefile.am b/build/Makefile.am
new file mode 100644
index 000000000..9c196a8f1
--- /dev/null
+++ b/build/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = windows
diff --git a/build/windows/Makefile.am b/build/windows/Makefile.am
new file mode 100644
index 000000000..65f8c9b4b
--- /dev/null
+++ b/build/windows/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = installer
diff --git a/build/windows/installer/Makefile.am b/build/windows/installer/Makefile.am
new file mode 100644
index 000000000..77b229c63
--- /dev/null
+++ b/build/windows/installer/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = lang
diff --git a/build/windows/installer/gimp-help.iss b/build/windows/installer/gimp-help.iss
index b9151824b..536b2f832 100644
--- a/build/windows/installer/gimp-help.iss
+++ b/build/windows/installer/gimp-help.iss
@@ -135,7 +135,7 @@ PrivilegesRequired=lowest
 PrivilegesRequiredOverridesAllowed=commandline
 
 [Languages]
-Name: "{#LANG}"; MessagesFile: "compiler:{#LANGFILE},lang\help.en.isl"
+Name: "{#LANG}"; MessagesFile: "compiler:{#LANGFILE},lang\help.en.isl,lang\help.{#LANG}.isl"
 
 [Files]
 #ifndef nofiles
diff --git a/build/windows/installer/lang/Makefile.am b/build/windows/installer/lang/Makefile.am
new file mode 100644
index 000000000..7d66ea4c4
--- /dev/null
+++ b/build/windows/installer/lang/Makefile.am
@@ -0,0 +1,45 @@
+isl_in_files = \
+       help.isl.in
+isl_files = $(isl_in_files:.isl.in=.isl)
+
+stamp_files = \
+       stamp-isl
+
+CLEANFILES = $(isl_files) $(stamp_files)
+
+stamp-isl: help.isl Makefile.am
+       @                                                                                       \
+       for lang in $(top_srcdir)/po/*/; do                                                     \
+               code=`basename $$lang`;                                                         \
+               prefix="\\[$$code\\]";                                                          \
+               isl="$(builddir)/help.$$code.isl";                                              \
+               echo "  GEN      $$isl";                                                        \
+               echo -ne "\\xEF\\xBB\\xBF" > "$$isl";                                           \
+               sed '/^\w\+'"$$prefix"'=/{s/\(.\)'"$$prefix"'/\1/;n};/^\w.*=/d' $<  >> "$$isl"; \
+       done &&                                                                                 \
+       code="en" &&                                                                            \
+       prefix="" &&                                                                            \
+       isl="$(builddir)/help.$$code.isl" &&                                                    \
+       echo "  GEN      $$isl" &&                                                              \
+       echo -ne "\\xEF\\xBB\\xBF" > "$$isl" &&                                                 \
+       sed '/^\w\+'"$$prefix"'=/{s/\(.\)'"$$prefix"'/\1/;n};/^\w.*=/d' $<  >> "$$isl" &&       \
+       echo timestamp > stamp-isl
+
+help.isl: help.isl.in $(wildcard $(top_srcdir)/po-windows-installer/*.po) Makefile.am
+       $(AM_V_GEN) $(INTLTOOL_MERGE) $(top_srcdir)/po-windows-installer $< $(@) -d -u -c 
$(top_builddir)/po-windows-installer/.intltool-merge-cache
+
+all-local: $(stamp_files)
+
+clean-local:
+       @                                               \
+       for lang in $(top_srcdir)/po/*/; do                                                     \
+               code=`basename $$lang`;                                 \
+               isl="$(builddir)/help.$$code.isl";      \
+               echo "  RM       $$isl";                \
+               rm -f "$$isl";                          \
+       done
+
+TESTS_ENVIRONMENT = \
+       GIMP_TESTING_ABS_TOP_SRCDIR=@abs_top_srcdir@
+
+TESTS = test-installer-langs.sh
diff --git a/build/windows/installer/lang/help.isl.in b/build/windows/installer/lang/help.isl.in
new file mode 100644
index 000000000..f5bf466bb
--- /dev/null
+++ b/build/windows/installer/lang/help.isl.in
@@ -0,0 +1,10 @@
+;[Messages]
+;WelcomeLabel1=Welcome to the GIMP Help Setup Wizard
+
+[CustomMessages]
+_GimpHelp=GIMP Help
+_MissingParameters=Parameter /INSTALL requires parameters /DIR and /ALLUSERS or /CURRENTUSER.
+_NoGimpInstallsFound=No suitable GIMP installations were found. %1 can only be installed when GIMP %2 is 
already present.
+;DirNotGimp=GIMP does not appear to be installed in the selected directory. Continue anyway?
+_SelectGimpInstallsCaption=Multiple GIMP installations were found
+_SelectGimpInstallsDescription=Select all installs for which you want to install %1
diff --git a/configure.ac b/configure.ac
index 5a883c926..bc8a90b8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -195,6 +195,25 @@ AC_SUBST(MSGCATFLAGS)
 MSGWIDTH=79
 AC_SUBST(MSGWIDTH)
 
+# Not calling:
+# IT_PROG_INTLTOOL(intltool_required_version)
+# on purpose because it tries to init po/ and we don't want this as we
+# handle our main docs po files differently. So checking the tools we
+# need individually for po-windows-installer/.
+
+AC_PATH_PROG(INTLTOOL_MERGE, intltool-merge)
+if test -z "$INTLTOOL_MERGE" && test "x$enable_i18n" = "xyes"; then
+  missing_i18n_tools=${missing_i18n_tools:+"${missing_i18n_tools} "}intltool-merge
+fi
+AC_PATH_PROG(INTLTOOL_UPDATE, intltool-update)
+if test -z "$INTLTOOL_UPDATE" && test "x$enable_i18n" = "xyes"; then
+  missing_i18n_tools=${missing_i18n_tools:+"${missing_i18n_tools} "}intltool-update
+fi
+AC_PATH_PROG(INTLTOOL_EXTRACT, intltool-extract)
+if test -z "$INTLTOOL_EXTRACT" && test "x$enable_i18n" = "xyes"; then
+  missing_i18n_tools=${missing_i18n_tools:+"${missing_i18n_tools} "}intltool-extract
+fi
+
 #  Optional: dot to create build system map
 
 AC_PATH_PROG(DOT, dot)
@@ -319,13 +338,44 @@ fi
 
 
 AC_CONFIG_FILES([
+build/Makefile
+build/windows/Makefile
+build/windows/installer/Makefile
+build/windows/installer/lang/Makefile
 m4macros/Makefile
 Makefile
+po-windows-installer/Makefile.in
 quickreference/Makefile
 stylesheets/plainhtml.xsl
 stylesheets/htmlalternate.xsl
 ])
 
+# By default, autoconf will create only po/Makefile.
+# This code is used to create the POTFILES and Makefile for all
+# additional gettext catalogs.
+m4_define([generate_po_makefile], [
+  AC_MSG_NOTICE([Generating POTFILES and Makefile for $1])
+
+  AC_CONFIG_COMMANDS([$1/stamp-it],
+  [[
+    if  ! grep "^# INTLTOOL_MAKEFILE$" "$1/Makefile.in" > /dev/null ; then
+       as_fn_error $? "$1/Makefile.in.in was not created by intltoolize." "$LINENO" 5
+    fi
+    rm -f "$1/stamp-it" "$1/POTFILES"
+    sed -e '/^#/d' -e 's/^[[].*] *//' \
+        -e '/^[        ]*$/d'        \
+        -e "s|^|       $ac_top_srcdir/|" \
+        "$srcdir/$1/POTFILES.in" | sed '$!s/$/ \\/' >"$1/POTFILES" && \
+    sed -e "/^# This comment gets stripped out/ {"  \
+        -e 'r $1/POTFILES'                          \
+        -e "d" -e "}"                               \
+        "$1/Makefile.in" >"$1/Makefile" && \
+    touch "$1/stamp-it"
+  ]])
+])
+
+generate_po_makefile([po-windows-installer])
+
 AC_OUTPUT
 
 AC_MSG_RESULT([
diff --git a/po-windows-installer/Makefile.in.in b/po-windows-installer/Makefile.in.in
new file mode 100644
index 000000000..1a47c8ec6
--- /dev/null
+++ b/po-windows-installer/Makefile.in.in
@@ -0,0 +1,234 @@
+# Makefile for program source directory in GNU NLS utilities package.
+# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper gnu ai mit edu>
+#
+# This file file be copied and used freely without restrictions.  It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+#
+# - Modified by Owen Taylor <otaylor redhat com> to use GETTEXT_PACKAGE
+#   instead of PACKAGE and to look for po2tbl in ./ not in intl/
+#
+# - Modified by jacob berkman <jacob ximian com> to install
+#   Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
+#
+# - Modified by Rodney Dawes <dobey novell com> for use with intltool
+#
+# We have the following line for use by intltoolize:
+# INTLTOOL_MAKEFILE
+
+GETTEXT_PACKAGE = gimp-help-windows-installer
+XGETTEXT_KEYWORDS=--keyword=_ --keyword=N_ --keyword=Q_:1g --keyword=C_:1c,2 --keyword=NC_:1c,2
+
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SHELL = /bin/sh
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+datadir = @datadir@
+datarootdir = @datarootdir@
+libdir = @libdir@
+DATADIRNAME = @DATADIRNAME@
+itlocaledir = $(prefix)/$(DATADIRNAME)/locale
+subdir = po-windows-installer
+install_sh = @install_sh@
+# Automake >= 1.8 provides @mkdir_p@.
+# Until it can be supposed, use the safe fallback:
+mkdir_p = $(install_sh) -d
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+
+GMSGFMT = @GMSGFMT@
+MSGFMT = @MSGFMT@
+XGETTEXT = @XGETTEXT@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+MSGINIT  = @MSGINIT@
+MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package 
$(GETTEXT_PACKAGE) --dist
+GENPOT   = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package 
$(GETTEXT_PACKAGE) --pot
+
+USE_NLS = no
+
+ALL_LINGUAS = @ALL_LINGUAS@
+
+PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi)
+
+USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for 
lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS`" -o -n "`echo $$ALINGUAS|grep ' ?$$lang 
?'`"; then printf "$$lang "; fi; done; fi)
+
+USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n 
"$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in 
$$LLINGUAS; do printf "$$lang "; done)
+
+POFILES=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
+
+#DISTFILES = Makefile.in.in POTFILES.in $(POFILES)
+#EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
+DISTFILES = Makefile.in.in POTFILES.in
+
+POTFILES = \
+# This comment gets stripped out
+
+CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done)
+
+.SUFFIXES:
+.SUFFIXES: .po .pox .gmo .mo .msg .cat
+
+.po.pox:
+       $(MAKE) $(GETTEXT_PACKAGE).pot
+       $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox
+
+.po.mo:
+       $(MSGFMT) -o $@ $<
+
+.po.gmo:
+       file=`echo $* | sed 's,.*/,,'`.gmo \
+         && rm -f $$file && $(GMSGFMT) -o $$file $<
+
+.po.cat:
+       sed -f ../intl/po2msg.sed < $< > $*.msg \
+         && rm -f $@ && gencat $@ $*.msg
+
+
+all: all-$(USE_NLS)
+
+all-yes: $(CATALOGS)
+all-no:
+
+$(GETTEXT_PACKAGE).pot: $(POTFILES)
+       @if test "x$(INTLTOOL_UPDATE)" = "x/bin/true"; then \
+               echo "Warning: pot generation deactivated on VPATH builds."; \
+               echo "         See commit c96006919."; \
+       fi
+       $(GENPOT)
+
+install: install-data
+install-data: install-data-$(USE_NLS)
+install-data-no: all
+install-data-yes: all
+       $(mkdir_p) $(DESTDIR)$(itlocaledir)
+       linguas="$(USE_LINGUAS)"; \
+       for lang in $$linguas; do \
+         dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \
+         $(mkdir_p) $$dir; \
+         if test -r $$lang.gmo; then \
+           $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
+           echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \
+         else \
+           $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
+           echo "installing $(srcdir)/$$lang.gmo as" \
+                "$$dir/$(GETTEXT_PACKAGE).mo"; \
+         fi; \
+         if test -r $$lang.gmo.m; then \
+           $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \
+           echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \
+         else \
+           if test -r $(srcdir)/$$lang.gmo.m ; then \
+             $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \
+               $$dir/$(GETTEXT_PACKAGE).mo.m; \
+             echo "installing $(srcdir)/$$lang.gmo.m as" \
+                  "$$dir/$(GETTEXT_PACKAGE).mo.m"; \
+           else \
+             true; \
+           fi; \
+         fi; \
+       done
+
+# Empty stubs to satisfy archaic automake needs
+dvi info tags TAGS ID:
+
+# Define this as empty until I found a useful application.
+install-exec installcheck:
+
+uninstall:
+       linguas="$(USE_LINGUAS)"; \
+       for lang in $$linguas; do \
+         rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
+         rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \
+       done
+
+check: check-$(USE_NLS)
+check-yes: all $(GETTEXT_PACKAGE).pot
+       rm -f missing notexist
+       srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m
+       if [ -r missing -o -r notexist ]; then \
+         exit 1; \
+       fi
+check-no: all
+
+mostlyclean:
+       rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
+       rm -f .intltool-merge-cache
+
+clean: mostlyclean
+
+distclean: clean
+       rm -f Makefile Makefile.in POTFILES stamp-it
+       rm -f *.mo *.msg *.cat *.cat.m *.gmo
+
+maintainer-clean: distclean
+       @echo "This command is intended for maintainers to use;"
+       @echo "it deletes files that may require special tools to rebuild."
+       rm -f Makefile.in.in
+
+distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
+dist distdir: $(DISTFILES)
+       dists="$(DISTFILES)"; \
+       extra_dists="$(EXTRA_DISTFILES)"; \
+       for file in $$extra_dists; do \
+         test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \
+       done; \
+       for file in $$dists; do \
+         test -f $$file || file="$(srcdir)/$$file"; \
+         ln $$file $(distdir) 2> /dev/null \
+           || cp -p $$file $(distdir); \
+       done
+
+update-po: Makefile
+       $(MAKE) $(GETTEXT_PACKAGE).pot
+       tmpdir=`pwd`; \
+       linguas="$(USE_LINGUAS)"; \
+       for lang in $$linguas; do \
+         test "x$$lang" != "xen" || continue; \
+         echo "$$lang:"; \
+         if test ! -f $(srcdir)/$$lang.po; then \
+           $(MSGINIT) --no-translator --input=$(GETTEXT_PACKAGE).pot --locale=$$lang 
--output=$(srcdir)/$$lang.po; \
+         fi; \
+         result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
+         if $$result; then \
+           if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+             rm -f $$tmpdir/$$lang.new.po; \
+            else \
+             if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
+               :; \
+             else \
+               echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
+               rm -f $$tmpdir/$$lang.new.po; \
+               exit 1; \
+             fi; \
+           fi; \
+         else \
+           echo "msgmerge for $$lang.gmo failed!"; \
+           rm -f $$tmpdir/$$lang.new.po; \
+         fi; \
+       done
+
+Makefile POTFILES: stamp-it
+       @if test ! -f $@; then \
+         rm -f stamp-it; \
+         $(MAKE) stamp-it; \
+       fi
+
+stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in
+       cd $(top_builddir) \
+         && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \
+              $(SHELL) ./config.status
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/po-windows-installer/POTFILES.in b/po-windows-installer/POTFILES.in
new file mode 100644
index 000000000..2c30ea02f
--- /dev/null
+++ b/po-windows-installer/POTFILES.in
@@ -0,0 +1,6 @@
+# Files from the Gimp distribution which have already been
+# marked to allow runtime translation of messages
+
+[encoding: UTF-8]
+
+[type: gettext/ini] build/windows/installer/lang/help.isl.in
diff --git a/po-windows-installer/POTFILES.skip b/po-windows-installer/POTFILES.skip
new file mode 100644
index 000000000..bba91dc5b
--- /dev/null
+++ b/po-windows-installer/POTFILES.skip
@@ -0,0 +1,8 @@
+build
+docs
+images
+quickreference
+src
+stylesheets
+tools
+web


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]