From ddd32e838c2cc04e988738a4d70cfddaf2f7df03 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Fri, 26 Aug 2022 12:05:18 +0100 Subject: [PATCH] Migrate build from intltool to gettext translation (!107) [0] GNOME Goal: Gettext Migration https://wiki.gnome.org/Initiatives/GnomeGoals/GettextMigration This goal from 2016 is to migrate away from using intltool to help translate especially GNOME application related files, and instead use gettext directly now that gettext can handle a lot more file formats [1][2][3]. The GNOME Goal: Gettext Migration [0] says: "With gettext 0.19.8, there is really no need anymore to use intltool or GLib's dated gettext glue (AM_GLIB_GNU_GETTEXT and glib-gettextize)." This version or later of gettext is available in the oldest supported distributions except for SLES 12: Distribution EOL gettext -V Debian 10 2022-Aug 0.19.8.1 RHEL / CentOS 7 2024-Jun 0.19.8.1 Ubuntu 18.04 LTS 2023-Apr 0.19.8.1 SLES 12 SP5 2024-Oct 0.19.2 [4][5] As SLES 12 SP5 doesn't contain GParted and SLES 15 contains GParted 0.31.0 [6] loosing the ability to compile future GParted 1.5 release on SLES 12 SP5 is acceptable. Additionally the use of intltool and the associated GLib provided macro AM_GLIB_GNU_GETTEXT was the source of the remaining warnings from autoconf 2.71 seen in Fedora 36 and Ubuntu 22.04 LTS about the use of obsolete macros: $ ./autogen.sh ... autoreconf: running: /usr/bin/autoconf --force configure.ac:59: warning: The macro `GLIB_GNU_GETTEXT' is obsolete. configure.ac:59: You should run autoupdate. aclocal.m4:426: GLIB_GNU_GETTEXT is expanded from... >> aclocal.m4:526: AM_GLIB_GNU_GETTEXT is expanded from... >> configure.ac:59: the top level configure.ac:59: warning: The macro `AC_TRY_LINK' is obsolete. configure.ac:59: You should run autoupdate. ./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from... lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from... lib/m4sugar/m4sh.m4:699: AS_IF is expanded from... ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from... ./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from... aclocal.m4:111: GLIB_LC_MESSAGES is expanded from... aclocal.m4:426: GLIB_GNU_GETTEXT is expanded from... >> aclocal.m4:526: AM_GLIB_GNU_GETTEXT is expanded from... >> configure.ac:59: the top level configure.ac:59: warning: The macro `AC_TRY_LINK' is obsolete. configure.ac:59: You should run autoupdate. ... Note that use of AM_GLIB_GNU_GETTEXT was deprecated in GLib 2.47.5 released 2016-01-18 [7]. Newer versions of GLib are included in the oldest supported distributions: Distro Package containing Version glib-gettext.m4 Debian 10 libglib2.0-dev-bin 2.58.3 RHEL / CentOS 7 glib2-devel 2.56.1 Ubuntu 18.04 LTS libglib2.0-dev-bin 2.56.4 SLES 12 SP5 glib2-devel 2.48.2 Therefore perform the migration described in the GNOME wiki documents [0][1]. This involves: 1. Replacing the macros used in configure.ac; 2. Copying Makevars.template to po/Makevars and setting PO_DEPENDS_ON_POT and DIST_DEPENDS_ON_UPDATE_PO to "no"; 3. Replace @INTLTOOL_*@ macros in Makefile.am with rules to use gettext to directly translate the relevent GNOME application files; 4. Removing (_) underscore marking translation prefixes from XML tags in GNOME application files as gettext understands which tags of which files need translating. For reference are these commits in projects GNOME-System-Monitor [8], Reversi [9] and Evince [10] making the same transition. At this point "./autogen.sh && make" succeeds, at least on Ubuntu which provides the instructions gettext needs to correctly translate .policy files by default. These: /usr/share/gettext/its/polkit.its /usr/share/gettext/its/polkit.loc are included in the base policykit-1 package. [1] Migrating from Intltool to Gettext https://wiki.gnome.org/MigratingFromIntltoolToGettext [2] Using Modern Gettext https://blogs.gnome.org/mclasen/2016/07/21/using-modern-gettext/ [3] On the killing of intltool https://blogs.gnome.org/mcatanzaro/2016/07/27/on-the-killing-of-intltool/ [4] SUSE package search, SLES 12 SP5, gettext https://scc.suse.com/packages?name=SUSE%20Linux%20Enterprise%20Server&version=12.5&arch=x86_64&query=gettext&module= [5] SUSE Long Term Service Pack Support https://links.imagerelay.com/cdn/3404/ql/f3a083e9bcd34c76addd096d7f60ec00/long_term_service_pack_support_flyer.pdf [6] SUSE package search, SLES 15, gparted https://scc.suse.com/packages?name=SUSE%20Linux%20Enterprise%20Server&version=15&arch=x86_64&query=gparted&module= [7] Deprecate GLIB_GNU_GETTEXT macro, use upstream gettext instead https://gitlab.gnome.org/GNOME/glib/-/commit/6b577196eed0754d2805fd48caa64f58f9bb8ee4 [8] [GNOME-System-Monitor] Migrate from intltool https://gitlab.gnome.org/GNOME/gnome-system-monitor/-/commit/9185b9c713980391a6f1a2377eb5ea249a0df182 [9] [Reversi] Gettext migration (bgo#793040) https://gitlab.gnome.org/GNOME/iagno/-/commit/d22f560ac80d0ded2cb3a38cb10a65e17ead3850 [10] [Evince] build: Migrate from Intltool to Gettext https://gitlab.gnome.org/GNOME/evince/-/commit/4fd682132430feb8c012e4b0aa0c2c5da5ffe5ac Closes !107 - Migrate from intltool to gettext translation --- Makefile.am | 21 ++++----- configure.ac | 5 ++- gparted.appdata.xml.in | 16 +++---- gparted.desktop.in.in | 10 ++--- org.gnome.gparted.policy.in.in | 4 +- po/Makevars | 78 ++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 27 deletions(-) create mode 100644 po/Makevars diff --git a/Makefile.am b/Makefile.am index c2accc26..f7074b2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,23 +7,30 @@ if BUILD_HELP_DOC SUBDIRS += help endif -@INTLTOOL_DESKTOP_RULE@ DESKTOP_IN_IN_FILES = gparted.desktop.in.in DESKTOP_IN_FILES = gparted.desktop.in DESKTOP_FILES =$(DESKTOP_IN_FILES:.desktop.in=.desktop) desktopdir = $(datadir)/applications desktop_DATA = $(DESKTOP_FILES) -@INTLTOOL_XML_RULE@ +$(DESKTOP_FILES): $(DESKTOP_IN_FILES) + $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ + APPDATA_IN_FILES = gparted.appdata.xml.in APPDATA_FILES =$(APPDATA_IN_FILES:.xml.in=.xml) appdatadir = $(datadir)/appdata appdata_DATA = $(APPDATA_FILES) -@INTLTOOL_POLICY_RULE@ +$(APPDATA_FILES): $(APPDATA_IN_FILES) + $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ + polkit_action_in_in_FILES = org.gnome.gparted.policy.in.in polkit_action_in_FILES = org.gnome.gparted.policy.in polkit_action_FILES = $(polkit_action_in_FILES:.policy.in=.policy) + +$(polkit_action_FILES): $(polkit_action_in_FILES) + $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ + polkit_actiondir = $(datadir)/polkit-1/actions if INSTALL_POLKIT_ACTIONS polkit_action_DATA = $(polkit_action_FILES) @@ -76,15 +83,9 @@ EXTRA_DIST = \ $(DESKTOP_IN_IN_FILES) \ $(DESKTOP_FILES) \ $(polkit_action_in_in_FILES) \ - intltool-extract.in \ - intltool-merge.in \ - intltool-update.in \ gparted.in DISTCLEANFILES = \ $(appdata_DATA) \ $(desktop_DATA) \ - $(polkit_action_DATA) \ - intltool-extract \ - intltool-merge \ - intltool-update + $(polkit_action_DATA) diff --git a/configure.ac b/configure.ac index 6bde555a..bda0ceb3 100644 --- a/configure.ac +++ b/configure.ac @@ -56,8 +56,9 @@ GETTEXT_PACKAGE=gparted AC_SUBST([GETTEXT_PACKAGE]) AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], "$GETTEXT_PACKAGE", [description]) -AM_GLIB_GNU_GETTEXT -IT_PROG_INTLTOOL([0.36.0]) +AM_GNU_GETTEXT_VERSION([0.19.8]) +AM_GNU_GETTEXT([external]) + dnl Check for and fix missing delete of intltool cache lock file. Only dnl needed with intltool >= 0.51.0-5.1, but just always fix as that is diff --git a/gparted.appdata.xml.in b/gparted.appdata.xml.in index 843a901b..2c180939 100644 --- a/gparted.appdata.xml.in +++ b/gparted.appdata.xml.in @@ -4,24 +4,24 @@ gparted.desktop GFDL-1.3 GPL-2.0+ - <_name>GParted Partition Editor - <_summary>Create, reorganize, and delete partitions + GParted Partition Editor + Create, reorganize, and delete partitions - <_p> +

GParted is a free partition editor for graphically managing your disk partitions. - - <_p> +

+

With GParted you can resize, copy, label, and move partitions without data loss. These actions enable you to grow or shrink your C: drive, create space for new operating systems, or attempt data rescue from lost partitions. - - <_p> +

+

GParted works with many file systems including: btrfs, exfat, ext2, ext3, ext4, fat16, fat32, hfs, hfs+, linux-swap, lvm2 pv, minix, nilfs2, ntfs, reiserfs, reiser4, udf, ufs, and xfs. - +

gparted.desktop diff --git a/gparted.desktop.in.in b/gparted.desktop.in.in index 3712b7dc..57b9245b 100644 --- a/gparted.desktop.in.in +++ b/gparted.desktop.in.in @@ -1,12 +1,12 @@ [Desktop Entry] -_Name=GParted -_GenericName=Partition Editor -_X-GNOME-FullName=GParted Partition Editor -_Comment=Create, reorganize, and delete partitions +Name=GParted +GenericName=Partition Editor +X-GNOME-FullName=GParted Partition Editor +Comment=Create, reorganize, and delete partitions Exec=@bindir@/gparted %f Icon=gparted Terminal=false Type=Application Categories=GNOME;System;Filesystem; -_Keywords=Partition; +Keywords=Partition; StartupNotify=true diff --git a/org.gnome.gparted.policy.in.in b/org.gnome.gparted.policy.in.in index f0e213ac..ef922f84 100644 --- a/org.gnome.gparted.policy.in.in +++ b/org.gnome.gparted.policy.in.in @@ -8,8 +8,8 @@ gparted - <_description>Run GParted as root - <_message>Authentication is required to run the GParted Partition Editor as root + Run GParted as root + Authentication is required to run the GParted Partition Editor as root auth_admin auth_admin diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 00000000..579ebd17 --- /dev/null +++ b/po/Makevars @@ -0,0 +1,78 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# 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 = + +# 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 = + +# 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, +# --quiet to reduce the verbosity. +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 = no + +# 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 = no