This patch adds two Makefile targets to gnulib's main Makefile:
  - A target for creating a tarball that can be handed to the TP's
    translation coordinator.
  - A target for creating a tarball that contains the localization
    of the "gnulib" domain.


2024-12-08  Bruno Haible  <br...@clisp.org>

        Add infrastructure for handling gnulib localizations.
        * po/Makefile: New file.
        * po/Makevars: New file, based on the template from GNU gettext.
        * gnulib-l10n/README: New file.
        * gnulib-l10n/configure.ac: New file.
        * gnulib-l10n/Makefile.am: New file.
        * gnulib-l10n/m4/Makefile.am: New file.
        * gnulib-l10n/autogen.sh: New file.
        * gnulib-l10n/autoclean.sh: New file.
        * Makefile (gnulib.pot, gnulib-tp-snapshot, gnulib-l10n-release): New
        targets.

>From 9cc4d2310c94509c4bc8adf5fb96d5434fa64088 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 8 Dec 2024 17:40:53 +0100
Subject: [PATCH] Add infrastructure for handling gnulib localizations.

* po/Makefile: New file.
* po/Makevars: New file, based on the template from GNU gettext.
* gnulib-l10n/README: New file.
* gnulib-l10n/configure.ac: New file.
* gnulib-l10n/Makefile.am: New file.
* gnulib-l10n/m4/Makefile.am: New file.
* gnulib-l10n/autogen.sh: New file.
* gnulib-l10n/autoclean.sh: New file.
* Makefile (gnulib.pot, gnulib-tp-snapshot, gnulib-l10n-release): New
targets.
---
 .gitignore                 |  1 +
 ChangeLog                  | 14 ++++++
 Makefile                   | 72 ++++++++++++++++++++++++++++++
 gnulib-l10n/Makefile.am    | 21 +++++++++
 gnulib-l10n/README         |  4 ++
 gnulib-l10n/autoclean.sh   | 53 +++++++++++++++++++++++
 gnulib-l10n/autogen.sh     | 19 ++++++++
 gnulib-l10n/configure.ac   | 33 ++++++++++++++
 gnulib-l10n/m4/Makefile.am | 22 ++++++++++
 po/Makefile                | 18 ++++++++
 po/Makevars                | 89 ++++++++++++++++++++++++++++++++++++++
 11 files changed, 346 insertions(+)
 create mode 100644 gnulib-l10n/Makefile.am
 create mode 100644 gnulib-l10n/README
 create mode 100755 gnulib-l10n/autoclean.sh
 create mode 100755 gnulib-l10n/autogen.sh
 create mode 100644 gnulib-l10n/configure.ac
 create mode 100644 gnulib-l10n/m4/Makefile.am
 create mode 100644 po/Makefile
 create mode 100644 po/Makevars

diff --git a/.gitignore b/.gitignore
index b95fb408d5..fae3b941a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
 allsnippets.tmp
 amsnippet.tmp
 testdir*
+/po/gnulib.pot
diff --git a/ChangeLog b/ChangeLog
index daed137dfe..82f7081b69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-12-08  Bruno Haible  <br...@clisp.org>
+
+	Add infrastructure for handling gnulib localizations.
+	* po/Makefile: New file.
+	* po/Makevars: New file, based on the template from GNU gettext.
+	* gnulib-l10n/README: New file.
+	* gnulib-l10n/configure.ac: New file.
+	* gnulib-l10n/Makefile.am: New file.
+	* gnulib-l10n/m4/Makefile.am: New file.
+	* gnulib-l10n/autogen.sh: New file.
+	* gnulib-l10n/autoclean.sh: New file.
+	* Makefile (gnulib.pot, gnulib-tp-snapshot, gnulib-l10n-release): New
+	targets.
+
 2024-12-08  Bruno Haible  <br...@clisp.org>
 
 	bison-i18n: Improve usability.
diff --git a/Makefile b/Makefile
index 0f0b24ee96..f38619a653 100644
--- a/Makefile
+++ b/Makefile
@@ -14,10 +14,16 @@ SHELL=bash
 # Produce some files that are not stored in the repository.
 all:
 
+# ==============================================================================
+# Documentation
+
 # Produce the documentation in readable form.
 info html dvi pdf:
 	cd doc && $(MAKE) $@ && $(MAKE) mostlyclean
 
+# ==============================================================================
+# Various checks
+
 # Collect the names of rules starting with 'sc_'.
 syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p'\
 			Makefile))
@@ -246,6 +252,9 @@ sc_check_GL_INLINE_HEADER_use:
 sc_check_copyright:
 	@./check-copyright
 
+# ==============================================================================
+# Regenerating some files
+
 # Regenerate some files that are stored in the repository.
 regen: build-aux/bootstrap MODULES.html
 
@@ -261,6 +270,9 @@ build-aux/bootstrap: top/gen-bootstrap.sed top/bootstrap top/bootstrap-funclib.s
 MODULES.html: MODULES.html.sh
 	./MODULES.html.sh > MODULES.html
 
+# ==============================================================================
+# Updating copyright notices
+
 # A perl BEGIN block to set Y to the current year number and W to Y-1.
 _year_and_prev = BEGIN{@t=localtime(time); $$y=$$t[5]+1900; $$w=$$y-1}
 
@@ -305,3 +317,63 @@ update-copyright:
 	perl -pi -e							\
 	  '$(_year_and_prev) s/^(scriptversion=)$$w.*/$$1$$y-01-01.00/i' \
 	  build-aux/gendocs.sh
+
+# ==============================================================================
+# Maintaining localizations
+
+# Creates an up-to-date POT file (in the po/ directory).
+gnulib.pot:
+	cd po && make
+
+# Creates a snapshot tarball for the Translation Project. Once created,
+# 1. upload it to alpha.gnu.org via
+#    $ build-aux/gnupload --to alpha.gnu.org:gnulib gnulib-????????.tar.gz
+# 2. notify <coordina...@translationproject.org>
+gnulib-tp-snapshot: gnulib.pot
+	version=`date -u +"%Y%m%d"`; \
+	dir=gnulib-$$version; \
+	mkdir $$dir \
+	&& for file in `find lib -type f` `find po -type f` COPYING; do \
+	     case $$file in \
+	       *.orig | *.rej | *~ | '.#'* | '#'*'#' ) ;; \
+	       *) \
+	         mkdir -p $$dir/`dirname $$file` || exit 1; \
+	         ln $$file $$dir/$$file || exit 1; \
+	     esac; \
+	   done \
+	&& { echo 'This tarball contains the GNU gnulib sources relevant for translators.'; \
+	     echo 'It is only meant for use by the translators and the translation coordinator.'; \
+	     echo 'If you are a developer, use a git checkout of the GNU gnulib project instead.'; \
+	   } > $$dir/README \
+	&& tar --owner=root --group=root -cf $$dir.tar $$dir \
+	&& gzip -9 --force $$dir.tar \
+	&& rm -rf $$dir \
+	&& ls -l $$dir.tar.gz
+
+# Creates a tarball with the gnulib localizations. Once created,
+# 1. upload it to ftp.gnu.org via
+#    $ build-aux/gnupload --to ftp.gnu.org:gnulib gnulib-l10n-????????.tar.gz
+# 2. notify your preferred distros so that they pick it up.
+gnulib-l10n-release: gnulib.pot
+	cp doc/COPYING.LESSERv2 gnulib-l10n/COPYING
+	mkdir -p gnulib-l10n/po \
+	&& cp po/Makevars gnulib-l10n/po/Makevars \
+	&& cp po/gnulib.pot gnulib-l10n/po/gnulib.pot
+	cd gnulib-l10n \
+	&& ./autogen.sh \
+	&& (cd po \
+	    && rm -f *.po \
+	    && wget --mirror --level=1 -nd -nv -A.po https://translationproject.org/latest/gnulib/ \
+	    && touch POTFILES.in \
+	    && ls -1 *.po | LC_ALL=C sort | sed -e 's/\.po$$//' > LINGUAS \
+	    && for file in *.po; do msgmerge --update --lang=$${file%.po} --previous $$file gnulib.pot || exit 1; done \
+	    && for file in *.po; do msgfmt -c -o $${file%.po}.gmo $$file || exit 1; done \
+	   ) \
+	&& ./configure \
+	&& make distcheck \
+	&& mv gnulib-l10n-????????.tar.gz .. \
+	&& make distclean \
+	&& ./autoclean.sh
+	ls -l gnulib-l10n-????????.tar.gz
+
+# ==============================================================================
diff --git a/gnulib-l10n/Makefile.am b/gnulib-l10n/Makefile.am
new file mode 100644
index 0000000000..3c16fc7892
--- /dev/null
+++ b/gnulib-l10n/Makefile.am
@@ -0,0 +1,21 @@
+## Makefile for the toplevel directory of the GNU gnulib localizations
+## Copyright (C) 2024 Free Software Foundation, Inc.
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+## Process this file with automake to produce Makefile.in.
+
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = m4 po
diff --git a/gnulib-l10n/README b/gnulib-l10n/README
new file mode 100644
index 0000000000..b8d0a160ed
--- /dev/null
+++ b/gnulib-l10n/README
@@ -0,0 +1,4 @@
+This package contains the localizations (translations) of messages for
+GNU gnulib code.
+
+It is under LGPLv2+.
diff --git a/gnulib-l10n/autoclean.sh b/gnulib-l10n/autoclean.sh
new file mode 100755
index 0000000000..87fc317a33
--- /dev/null
+++ b/gnulib-l10n/autoclean.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# GNU gnulib localizations.
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+rm -rf autom4te.cache
+
+# Brought in by autopoint.
+rm -f ABOUT-NLS
+rm -f config.rpath
+rm -f m4/gettext.m4
+rm -f m4/build-to-host.m4
+rm -f m4/host-cpu-c-abi.m4
+rm -f m4/iconv.m4
+rm -f m4/intlmacosx.m4
+rm -f m4/lib-ld.m4
+rm -f m4/lib-link.m4
+rm -f m4/lib-prefix.m4
+rm -f m4/nls.m4
+rm -f m4/po.m4
+rm -f m4/progtest.m4
+rm -f po/Makefile.in.in
+rm -f po/remove-potcdate.sed
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Fetched from the Translation Project.
+rm -f po/*.po
+
+# Copied from elsewhere.
+rm -f COPYING
+rm -f po/Makevars
+rm -f po/gnulib.pot
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f INSTALL
+rm -f compile
+rm -f install-sh
+rm -f missing
+rm -f config.guess
+rm -f config.sub
+rm -f po/POTFILES.in
+rm -f po/LINGUAS
+rm -f po/stamp-po
+rm -f po/*.gmo
diff --git a/gnulib-l10n/autogen.sh b/gnulib-l10n/autogen.sh
new file mode 100755
index 0000000000..635300bf06
--- /dev/null
+++ b/gnulib-l10n/autogen.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# GNU gnulib localizations.
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+autopoint -f
+rm po/Makevars.template
+rm po/Rules-quot
+rm po/boldquot.sed
+rm po/en@boldquot.header
+rm po/en@quot.header
+rm po/insert-header.sed
+rm po/quot.sed
+
+aclocal -I m4
+autoconf
+automake --add-missing --copy
+rm -rf autom4te.cache
diff --git a/gnulib-l10n/configure.ac b/gnulib-l10n/configure.ac
new file mode 100644
index 0000000000..9359aa3238
--- /dev/null
+++ b/gnulib-l10n/configure.ac
@@ -0,0 +1,33 @@
+dnl Configuration for the GNU gnulib localizations
+dnl Copyright (C) 2024 Free Software Foundation, Inc.
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT([gnulib-l10n], m4_esyscmd([date -u +"%Y%m%d"]), [bug-gnulib@gnu.org])
+AC_CONFIG_SRCDIR([configure.ac])
+AM_INIT_AUTOMAKE([1.13 foreign tar-ustar])
+
+dnl Override automake's tar command used for creating distributions.
+am__tar='${AMTAR} chf - --format=ustar --owner=root --group=root "$$tardir"'
+
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.23])
+
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([m4/Makefile])
+AC_CONFIG_FILES([po/Makefile.in])
+
+AC_OUTPUT
diff --git a/gnulib-l10n/m4/Makefile.am b/gnulib-l10n/m4/Makefile.am
new file mode 100644
index 0000000000..2143d693db
--- /dev/null
+++ b/gnulib-l10n/m4/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile for the m4 directory of the GNU gnulib localizations
+## Copyright (C) 2024 Free Software Foundation, Inc.
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+## Process this file with automake to produce Makefile.in.
+
+EXTRA_DIST = \
+  gettext.m4 build-to-host.m4 host-cpu-c-abi.m4 \
+  iconv.m4 intlmacosx.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 \
+  nls.m4 po.m4 progtest.m4
diff --git a/po/Makefile b/po/Makefile
new file mode 100644
index 0000000000..7dfccb2db0
--- /dev/null
+++ b/po/Makefile
@@ -0,0 +1,18 @@
+all: gnulib.pot
+
+include Makevars
+
+VERSION != date -u +"%Y%m%d"
+
+$(DOMAIN).pot: force
+	xgettext --default-domain=$(DOMAIN) --directory=.. \
+	  --add-comments=TRANSLATORS: \
+	  --copyright-holder='$(COPYRIGHT_HOLDER)' \
+	  --package-name='GNU gnulib' \
+	  --package-version='$(VERSION)' \
+	  --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)' \
+	  $(XGETTEXT_OPTIONS) \
+	  `cd .. && LC_ALL=C grep -l '[^A-Za-z_]_(' \`find lib '(' -name '*.c' -o -name '*.h' -o -name '*.y' ')' | LC_ALL=C sort\``
+	mv $(DOMAIN).po $(DOMAIN).pot
+
+force:
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000000..6383129aa5
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,89 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+#
+# Copyright (C) 2003-2024 Free Software Foundation, Inc.
+# This file, Makevars, is free software; the Free Software Foundation
+# gives unlimited permission to use, copy, distribute, and modify it.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = gnulib
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = \
+  --keyword=_ --flag=_:1:pass-c-format \
+  --keyword=N_ --flag=N_:1:pass-c-format \
+  --flag=error:3:c-format --flag=error_at_line:5:c-format \
+  --flag=verror:3:c-format --flag=verror_at_line:5:c-format \
+  --flag=argp_error:2:c-format --flag=argp_failure:4:c-format \
+  --flag=asprintf:2:c-format --flag=vasprintf:2:c-format --flag=xasprintf:1:c-format \
+  --flag=aszprintf:2:c-format --flag=vaszprintf:2:c-format \
+  --flag=xprintf:1:c-format --flag=xvprintf:1:c-format --flag=xfprintf:2:c-format --flag=xvfprintf:2:c-format
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
+# package.  (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.)  Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright.  The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Free Software Foundation, Inc.
+
+# This tells whether or not to prepend "GNU " prefix to the package
+# name that gets inserted into the header of the $(DOMAIN).pot file.
+# Possible values are "yes", "no", or empty.  If it is empty, try to
+# detect it automatically by scanning the files in $(top_srcdir) for
+# "GNU packagename" string.
+PACKAGE_GNU = yes
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+#   in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+#   understood.
+# - Strings which make invalid assumptions about notation of date, time or
+#   money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used.  It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
+
+# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
+# context.  Possible values are "yes" and "no".  Set this to yes if the
+# package uses functions taking also a message context, like pgettext(), or
+# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
+USE_MSGCTXT = no
+
+# These options get passed to msgmerge.
+# Useful options are in particular:
+#   --previous            to keep previous msgids of translated messages
+MSGMERGE_OPTIONS =
+
+# These options get passed to msginit.
+# If you want to disable line wrapping when writing PO files, add
+# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
+# MSGINIT_OPTIONS.
+MSGINIT_OPTIONS =
+
+# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
+# has changed.  Possible values are "yes" and "no".  Set this to no if
+# the POT file is checked in the repository and the version control
+# program ignores timestamps.
+PO_DEPENDS_ON_POT = yes
+
+# This tells whether or not to forcibly update $(DOMAIN).pot and
+# regenerate PO files on "make dist".  Possible values are "yes" and
+# "no".  Set this to no if the POT file and PO files are maintained
+# externally.
+DIST_DEPENDS_ON_UPDATE_PO = yes
-- 
2.34.1

Reply via email to