From 7fcf43bf0125a1e8c1e611294441cff817f379d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Fri, 23 Feb 2018 08:04:20 +0100 Subject: [PATCH] build: Migrate from Intltool to Gettext Recent versions of Gettext are able to translate several formats that are used in GNOME applications. This patch migrates from Intltool to Gettext both autotools and meson. https://bugs.freedesktop.org/show_bug.cgi?id=105209 --- actions/Makefile.am | 7 +- actions/meson.build | 4 +- actions/org.freedesktop.policykit.policy.in | 4 +- autogen.sh | 11 ++- configure.ac | 8 ++- meson.build | 5 -- po/Makevars | 78 ++++++++++++++++++++++ po/POTFILES.in | 1 - src/examples/Makefile.am | 7 +- src/examples/meson.build | 4 +- ...freedesktop.policykit.examples.pkexec.policy.in | 4 +- 11 files changed, 109 insertions(+), 24 deletions(-) create mode 100644 po/Makevars diff --git a/actions/Makefile.am b/actions/Makefile.am index 1709992..0de3abb 100644 --- a/actions/Makefile.am +++ b/actions/Makefile.am @@ -1,9 +1,10 @@ polkit_actiondir = $(datadir)/polkit-1/actions +polkit_action_in_files = org.freedesktop.policykit.policy.in +dist_polkit_action_DATA = $(polkit_action_in_files:.policy.in=.policy) -dist_polkit_action_DATA = org.freedesktop.policykit.policy - -@INTLTOOL_POLICY_RULE@ +org.freedesktop.policykit.policy: org.freedesktop.policykit.policy.in + $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ #check: # $(top_builddir)/tools/polkit-policy-file-validate-1 $(top_srcdir)/policy/$(dist_polkit_action_DATA) diff --git a/actions/meson.build b/actions/meson.build index bb570b4..7072c36 100644 --- a/actions/meson.build +++ b/actions/meson.build @@ -1,10 +1,10 @@ policy = 'org.freedesktop.policykit.policy' -custom_target( +i18n.merge_file( policy, input: policy + '.in', output: policy, - command: intltool_xml_cmd, + po_dir: po_dir, install: true, install_dir: pk_actiondir ) diff --git a/actions/org.freedesktop.policykit.policy.in b/actions/org.freedesktop.policykit.policy.in index 7400b08..dc5c219 100644 --- a/actions/org.freedesktop.policykit.policy.in +++ b/actions/org.freedesktop.policykit.policy.in @@ -9,8 +9,8 @@ http://www.freedesktop.org/wiki/Software/polkit/ - <_description>Run a program as another user - <_message>Authentication is required to run a program as another user + Run a program as another user + Authentication is required to run a program as another user auth_admin auth_admin diff --git a/autogen.sh b/autogen.sh index 3407ae0..549d5a3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -69,6 +69,14 @@ test -n "$NO_AUTOMAKE" || (autoreconf --version) < /dev/null > /dev/null 2>&1 || DIE=1 } +# if no automake, don't bother testing for autopoint +test -n "$NO_AUTOMAKE" || (autopoint --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have autopoint installed." + echo "You can get autopoint from ..." + DIE=1 +} + if test "$DIE" -eq 1; then exit 1 @@ -103,13 +111,12 @@ esac echo "Running autoheader..." autoheader fi + autopoint --force echo "Running automake --gnu -Wno-portability $am_opt ..." automake --add-missing --gnu -Wno-portability $am_opt echo "Running autoconf ..." autoconf -intltoolize --copy --force --automake || exit 1 - cd "$olddir" conf_flags="--enable-maintainer-mode --enable-gtk-doc" diff --git a/configure.ac b/configure.ac index af2c8dd..c772e53 100644 --- a/configure.ac +++ b/configure.ac @@ -488,12 +488,16 @@ AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_examples" = "xyes") # Internationalization # ******************** -IT_PROG_INTLTOOL([0.40.0]) GETTEXT_PACKAGE=polkit-1 AC_SUBST([GETTEXT_PACKAGE]) -AM_GLIB_GNU_GETTEXT AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext domain]) +AX_REQUIRE_DEFINED([AM_GNU_GETTEXT_VERSION]) +AM_GNU_GETTEXT_VERSION([0.19.8]) + +AX_REQUIRE_DEFINED([AM_GNU_GETTEXT]) +AM_GNU_GETTEXT([external]) + AC_ARG_VAR([SUID_CFLAGS], [CFLAGS used for binaries which are usually with the suid bit]) AC_ARG_VAR([SUID_LDFLAGS], diff --git a/meson.build b/meson.build index ea893ca..5bf22d6 100644 --- a/meson.build +++ b/meson.build @@ -294,11 +294,6 @@ pkg = import('pkgconfig') data_dir = join_paths(meson.source_root(), 'data') po_dir = join_paths(meson.source_root(), 'po') -intltool_merge = find_program('intltool-merge') -intltool_cache = join_paths(po_dir, '.intltool-merge-cache') -intltool_desktop_cmd = [intltool_merge, '-d', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@'] -intltool_xml_cmd = [intltool_merge, '-x', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@'] - top_inc = include_directories('.', 'src') content_files = files('COPYING') diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..1cad43c --- /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 = polkit-1 + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments + +# 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 = polkit Authors + +# 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 = no + +# 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 = http://lists.freedesktop.org/mailman/listinfo/polkit-devel + +# 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 = yes + +# 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 diff --git a/po/POTFILES.in b/po/POTFILES.in index ed9faa5..0e15629 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,6 +1,5 @@ # List of source files containing translatable strings. # Please keep this file sorted alphabetically. -[encoding: UTF-8] actions/org.freedesktop.policykit.policy.in src/examples/org.freedesktop.policykit.examples.pkexec.policy.in src/programs/pkaction.c diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am index 3ee373f..b17009e 100644 --- a/src/examples/Makefile.am +++ b/src/examples/Makefile.am @@ -49,10 +49,11 @@ pk_example_frobnicate_LDADD = \ $(NULL) polkit_actiondir = $(datadir)/polkit-1/actions +polkit_action_in_files = org.freedesktop.policykit.examples.pkexec.policy.in +dist_polkit_action_DATA = $(polkit_action_in_files:.policy.in=.policy) -dist_polkit_action_DATA = org.freedesktop.policykit.examples.pkexec.policy - -@INTLTOOL_POLICY_RULE@ +org.freedesktop.policykit.examples.pkexec.policy: org.freedesktop.policykit.examples.pkexec.policy.in + $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ #check: # $(top_builddir)/tools/polkit-policy-file-validate-1 $(top_srcdir)/policy/$(dist_polkit_action_DATA) diff --git a/src/examples/meson.build b/src/examples/meson.build index 497fc5e..f0832a7 100644 --- a/src/examples/meson.build +++ b/src/examples/meson.build @@ -1,10 +1,10 @@ policy = 'org.freedesktop.policykit.examples.pkexec.policy' -custom_target( +i18n.merge_file( policy, input: policy + '.in', output: policy, - command: intltool_xml_cmd, + po_dir: po_dir, install: true, install_dir: pk_actiondir ) diff --git a/src/examples/org.freedesktop.policykit.examples.pkexec.policy.in b/src/examples/org.freedesktop.policykit.examples.pkexec.policy.in index eab7729..ec52416 100644 --- a/src/examples/org.freedesktop.policykit.examples.pkexec.policy.in +++ b/src/examples/org.freedesktop.policykit.examples.pkexec.policy.in @@ -7,8 +7,8 @@ http://www.freedesktop.org/wiki/Software/polkit/ - <_description>Run the polkit example program Frobnicate - <_message>Authentication is required to run the polkit example program Frobnicate (user=$(user), user.gecos=$(user.gecos), user.display=$(user.display), program=$(program), command_line=$(command_line)) + Run the polkit example program Frobnicate + Authentication is required to run the polkit example program Frobnicate (user=$(user), user.gecos=$(user.gecos), user.display=$(user.display), program=$(program), command_line=$(command_line)) audio-x-generic no -- 2.16.1