[gnome-nettool] build: Migrate from Intltool to Gettext



commit f247157fa194e4e941c8db9a4f937a7061dbb05a
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Sep 28 17:44:46 2017 +0200

    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 in autotools and modifies meson to use the
    same files.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788309

 Makefile.am                                        |   10 ---
 configure.ac                                       |    9 ++-
 data/Makefile.am                                   |   10 +-
 data/gnome-nettool.desktop.in.in                   |    6 +-
 data/gnome-nettool.desktop.in.meson                |   14 ----
 data/meson.build                                   |   15 +---
 ...l.meson => org.gnome.gnome-nettool.gschema.xml} |    0
 data/org.gnome.gnome-nettool.gschema.xml.in        |   20 -----
 meson.build                                        |    2 +
 po/Makevars                                        |   78 ++++++++++++++++++++
 po/POTFILES.in                                     |    8 +-
 11 files changed, 102 insertions(+), 70 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9f5fcd7..ba0a998 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,8 +3,6 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 SUBDIRS = pixmaps data src help po
 
 MESON_FILES = \
-       data/gnome-nettool.desktop.in.meson \
-       data/org.gnome.gnome-nettool.gschema.xml.meson \
        data/meson.build \
        help/meson.build \
        pixmaps/meson.build \
@@ -14,13 +12,5 @@ MESON_FILES = \
        meson.build
 
 EXTRA_DIST = \
-       intltool-extract.in \
-       intltool-merge.in \
-       intltool-update.in \
        mkinstalldirs \
        $(MESON_FILES)
-
-DISTCLEANFILES = \
-       intltool-extract \
-       intltool-merge \
-       intltool-update
diff --git a/configure.ac b/configure.ac
index 95f19ec..866e353 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,12 +44,15 @@ AC_SUBST(NETTOOL_LIBS)
 dnl
 dnl Translations
 dnl
-IT_PROG_INTLTOOL([0.40.0])
-
 GETTEXT_PACKAGE=gnome-nettool
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The gettext package])
-AM_GLIB_GNU_GETTEXT
+
+AX_REQUIRE_DEFINED([AM_GNU_GETTEXT_VERSION])
+AM_GNU_GETTEXT_VERSION([0.19.8])
+
+AX_REQUIRE_DEFINED([AM_GNU_GETTEXT])
+AM_GNU_GETTEXT([external])
 
 #User Documentation
 YELP_HELP_INIT
diff --git a/data/Makefile.am b/data/Makefile.am
index 7716694..2d9893d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,18 +2,18 @@ uidir = $(pkgdatadir)/ui
 ui_DATA = gnome-nettool.ui
 
 gsettings_SCHEMAS = org.gnome.gnome-nettool.gschema.xml
-@INTLTOOL_XML_NOMERGE_RULE@
 @GSETTINGS_RULES@
 
 desktopdir = $(datadir)/applications
 desktop_in_in_files = gnome-nettool.desktop.in.in
 desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-@INTLTOOL_DESKTOP_RULE@
 
-EXTRA_DIST =                                   \
-       $(desktop_in_in_files)                  \
-       org.gnome.gnome-nettool.gschema.xml.in  \
+gnome-nettool.desktop: gnome-nettool.desktop.in
+       $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
+
+EXTRA_DIST =                   \
+       $(desktop_in_in_files)  \
        $(ui_DATA)
 
 DISTCLEANFILES =                \
diff --git a/data/gnome-nettool.desktop.in.in b/data/gnome-nettool.desktop.in.in
index fa74fa6..74a601c 100644
--- a/data/gnome-nettool.desktop.in.in
+++ b/data/gnome-nettool.desktop.in.in
@@ -1,7 +1,7 @@
 [Desktop Entry]
-_Name=Network Tools
-_Comment=View information about your network
-_Keywords=network;monitor;remote;
+Name=Network Tools
+Comment=View information about your network
+Keywords=network;monitor;remote;
 Exec=gnome-nettool
 Icon=gnome-nettool
 Terminal=false
diff --git a/data/meson.build b/data/meson.build
index 32dff0a..250a35a 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -5,6 +5,7 @@ localedir = get_option('localedir')
 
 ui_dir = join_paths(prefix, datadir, pkg, 'ui', '') # want trailing slash
 pixmaps_dir = join_paths(prefix, datadir, pkg, 'pixmaps')
+schemas_dir = join_paths(prefix, datadir, 'glib-2.0', 'schemas')
 
 cdata.set_quoted('GNOME_NETTOOL_LOCALEDIR', join_paths(prefix, localedir))
 cdata.set_quoted('PIXMAPS_DIR', pixmaps_dir)
@@ -15,8 +16,7 @@ install_data('gnome-nettool.ui', install_dir: ui_dir)
 desktop_conf = configuration_data()
 desktop_conf.set('PACKAGE_VERSION', meson.project_version())
 
-# gnome-nettool.desktop.in.meson has leading _ removed for Name, Comment, Keywords
-desktop_in = configure_file(input: 'gnome-nettool.desktop.in.meson',
+desktop_in = configure_file(input: 'gnome-nettool.desktop.in.in',
                             output: 'gnome-nettool.desktop.in',
                             configuration: desktop_conf)
 
@@ -24,15 +24,8 @@ i18n.merge_file('desktop',
                 type: 'desktop',
                 input: desktop_in,
                 output: 'gnome-nettool.desktop',
-                po_dir: join_paths(meson.current_source_dir(), '../po'),
+                po_dir: po_dir,
                 install: true,
                 install_dir: join_paths(prefix, datadir, 'applications'))
 
-# FIXME: not sure how to do things with the orignal .in file with translatable xml tags
-# Apparently very very recent gettext (git) has gschema support.
-# Also: https://github.com/mesonbuild/meson/pull/1757
-configure_file(input: 'org.gnome.gnome-nettool.gschema.xml.meson',
-               output: 'org.gnome.gnome-nettool.gschema.xml',
-               configuration: configuration_data(),
-               install: true,
-               install_dir: join_paths(prefix, datadir, 'glib-2.0', 'schemas'))
+install_data('org.gnome.gnome-nettool.gschema.xml', install_dir: schemas_dir)
diff --git a/data/org.gnome.gnome-nettool.gschema.xml.meson b/data/org.gnome.gnome-nettool.gschema.xml
similarity index 100%
rename from data/org.gnome.gnome-nettool.gschema.xml.meson
rename to data/org.gnome.gnome-nettool.gschema.xml
diff --git a/meson.build b/meson.build
index 56d58d6..838baa2 100644
--- a/meson.build
+++ b/meson.build
@@ -43,6 +43,8 @@ gmodule_dep = dependency('gmodule-export-2.0')
 
 nettool_deps = [gtk_dep, gio_dep, gmodule_dep, gtop_dep]
 
+po_dir = join_paths(meson.source_root(), 'po')
+
 subdir('src')
 subdir('po')
 subdir('data')
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..5ace598
--- /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 = --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 = GNOME Nettool 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 = 
https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-nettool&keywords=I18N+L10N&component=general
+
+# 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 333d8a1..062a96e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,10 +1,11 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
+data/gnome-nettool.desktop.in.in
+data/gnome-nettool.ui
+data/org.gnome.gnome-nettool.gschema.xml
 src/callbacks.c
 src/callbacks.h
-data/gnome-nettool.desktop.in.in
-data/org.gnome.gnome-nettool.gschema.xml.in
-[type: gettext/glade]data/gnome-nettool.ui
+src/finger.c
 src/info.c
 src/info.h
 src/lookup.c
@@ -18,5 +19,4 @@ src/scan.c
 src/traceroute.c
 src/traceroute.h
 src/utils.c
-src/finger.c
 src/whois.c


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