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
     6b577196ee
[8]  [GNOME-System-Monitor] Migrate from intltool
     9185b9c713
[9]  [Reversi] Gettext migration (bgo#793040)
     d22f560ac8
[10] [Evince] build: Migrate from Intltool to Gettext
     4fd6821324

Closes !107 - Migrate from intltool to gettext translation
This commit is contained in:
Mike Fleetwood 2022-08-26 12:05:18 +01:00 committed by Curtis Gedak
parent 07382609b5
commit ddd32e838c
6 changed files with 107 additions and 27 deletions

View File

@ -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)

View File

@ -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

View File

@ -4,24 +4,24 @@
<id>gparted.desktop</id>
<metadata_license>GFDL-1.3</metadata_license>
<project_license>GPL-2.0+</project_license>
<_name>GParted Partition Editor</_name>
<_summary>Create, reorganize, and delete partitions</_summary>
<name>GParted Partition Editor</name>
<summary>Create, reorganize, and delete partitions</summary>
<description>
<_p>
<p>
GParted is a free partition editor for graphically managing your
disk partitions.
</_p>
<_p>
</p>
<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>
<_p>
</p>
<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.
</_p>
</p>
</description>
<launchable type="desktop-id">gparted.desktop</launchable>
<screenshots>

View File

@ -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

View File

@ -8,8 +8,8 @@
<icon_name>gparted</icon_name>
<action id="org.gnome.gparted">
<_description>Run GParted as root</_description>
<_message>Authentication is required to run the GParted Partition Editor as root</_message>
<description>Run GParted as root</description>
<message>Authentication is required to run the GParted Partition Editor as root</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>

78
po/Makevars Normal file
View File

@ -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