[sound-juicer/wip/gettext: 1/5] Replace Intltool with GNU Gettext



commit b3b9cb4dadae7d8e5ce400dba5766adb9703c298
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Tue Jun 14 10:40:34 2016 +0100

    Replace Intltool with GNU Gettext
    
    GNU Gettext 0.19.6 can translate appdata xml files and it is actively
    maintained which Intltool isn't.
    
    xgettext is unable to parse G_GNU_PRINTF annotations so add all the
    printf style functions from glib and gio with --flag. This ensures that
    when these functions are called with string literals which do not
    contain ‘%’ specifiers xgettext inserts ‘c-format’ comments into the pot
    file for msgfmt -c checks.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769623

 Makefile.am                              |    8 +-
 build-aux/git.mk                         |    7 ++-
 configure.ac                             |   16 +---
 data/Makefile.am                         |    9 ++-
 data/appdata/sound-juicer.appdata.xml.in |   12 ++--
 data/sound-juicer.desktop.in.in          |   10 +-
 po/Makevars                              |  124 ++++++++++++++++++++++++++++++
 po/POTFILES.in                           |    9 +-
 src/sj-main.c                            |   10 +-
 9 files changed, 166 insertions(+), 39 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c8e4613..5077490 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@ MAINTAINERCLEANFILES =
 
 sound_juicer_CPPFLAGS = \
        -I$(top_srcdir)/libjuicer \
-       -DGNOMELOCALEDIR=\""$(datadir)/locale"\"  \
+       -DLOCALEDIR=\""$(localedir)"\"  \
        -DTOPSRCDIR=\""$(top_srcdir)"\" \
        -DDATADIR=\""$(datadir)"\" \
        -DPREFIX=\""$(prefix)"\" \
@@ -29,11 +29,12 @@ sound_juicer_CFLAGS = \
        $(AM_CFLAGS)
 
 sound_juicer_LDADD = \
+       @LIBINTL@ \
        $(GSTREAMER_LIBS) \
        $(BURN_LIBS) \
        $(UI_LIBS)
 
-SUBDIRS = po help
+SUBDIRS = . po help
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
@@ -53,9 +54,8 @@ MAINTAINERCLEANFILES += \
        $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \
        $(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN) \
        $(GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL) \
+       ABOUT-NLS \
        INSTALL
 
-DISTCLEANFILES += po/.intltool-merge-cache
-
 -include $(top_srcdir)/build-aux/git.mk
 -include $(top_srcdir)/build-aux/release.mk
diff --git a/build-aux/git.mk b/build-aux/git.mk
index ef4919b..b7771e8 100644
--- a/build-aux/git.mk
+++ b/build-aux/git.mk
@@ -84,6 +84,7 @@ GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
                ar-lib \
                compile \
                config.guess \
+               config.rpath \
                config.sub \
                depcomp \
                install-sh \
@@ -230,11 +231,15 @@ $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/build-aux/git.mk
                                "po/*.mo" \
                                "po/*.sed" \
                                "po/*.sin" \
-                               po/$(GETTEXT_PACKAGE).pot \
                                intltool-extract.in \
                                intltool-merge.in \
                                intltool-update.in \
                        ; do echo "/$$x"; done; \
+                       if test -z "$(GETTEXT_PACKAGE)"; then \
+                               echo "/po/$(PACKAGE).pot"; \
+                       else \
+                               echo "/po/$(GETTEXT_PACKAGE).pot"; \
+                       fi; \
                fi; \
                if test -f $(srcdir)/configure; then \
                        for x in \
diff --git a/configure.ac b/configure.ac
index cfa123d..730a1e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_INIT([Sound 
Juicer],[3.20.0],[http://bugzilla.gnome.org/enter_bug.cgi?product=sound-juicer],[sound-juicer])
 
-AC_PREREQ(2.52)
+AC_PREREQ(2.60)
 
 AC_CONFIG_AUX_DIR([build-aux])
 
@@ -17,18 +17,16 @@ GNOME_DEBUG_CHECK
 
 AM_MAINTAINER_MODE([enable])
 
-# Do the gettext/i18n stuff
-GETTEXT_PACKAGE=sound-juicer
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The name of the gettext package.])
-AC_SUBST(GETTEXT_PACKAGE)
-AM_GLIB_GNU_GETTEXT
+# Use GNU Gettext
+AM_GNU_GETTEXT([external],[need-ngettext])
+AM_GNU_GETTEXT_VERSION([0.19.6])
 
 # Standard C and C++ compiler mojo
 AC_ISC_POSIX
 AM_PROG_CC_C_O
 AC_HEADER_STDC
 AC_PROG_INSTALL
-IT_PROG_INTLTOOL([0.50.0])
+AC_PROG_MKDIR_P
 
 GNOME_COMPILE_WARNINGS([maximum])
 
@@ -47,10 +45,6 @@ YELP_HELP_INIT
 # Appdata validation and installation
 APPSTREAM_XML
 
-# Ensure data/appdata exists under $(builddir)
-AC_PROG_MKDIR_P
-AC_CONFIG_COMMANDS([data/appdata], [$MKDIR_P data/appdata])
-
 # Find GLib and GObject
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.38 gthread-2.0 gobject-2.0 gio-2.0)
 AC_SUBST(GLIB_CFLAGS)
diff --git a/data/Makefile.am b/data/Makefile.am
index 28c50da..1da03fc 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,13 +1,18 @@
 desktopdir = $(datadir)/applications
 desktop_in_files = data/sound-juicer.desktop.in.in
 desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
-@INTLTOOL_DESKTOP_RULE@
 
-@INTLTOOL_XML_RULE@
+$(desktop_DATA): data/sound-juicer.desktop.in
+       $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
+
 @APPSTREAM_XML_RULES@
 appstream_XML = $(appstream_in_files:.xml.in=.xml)
 appstream_in_files = data/appdata/sound-juicer.appdata.xml.in
 
+$(appstream_XML): $(appstream_in_files)
+       $(MKDIR_P) data/appdata
+       $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
+
 gsettings_SCHEMAS = data/org.gnome.sound-juicer.gschema.xml
 
 @GSETTINGS_RULES@
diff --git a/data/appdata/sound-juicer.appdata.xml.in b/data/appdata/sound-juicer.appdata.xml.in
index f438954..4d953be 100644
--- a/data/appdata/sound-juicer.appdata.xml.in
+++ b/data/appdata/sound-juicer.appdata.xml.in
@@ -4,23 +4,23 @@
   <id>sound-juicer.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-2.0+</project_license>
-  <_name>Sound Juicer</_name>
-  <_summary>CD ripper with a clean interface and simple preferences</_summary>
+  <name>Sound Juicer</name>
+  <summary>CD ripper with a clean interface and simple preferences</summary>
   <description>
-    <_p>
+    <p>
       Sound Juicer is a simple and clean CD ripping tool.
       It allows you to extract the audio from audio compact discs and convert
       them into audio files that your computer can understand and play.
       Sound Juicer can also play the audio tracks directly from the CD, allowing
       you to preview the CD before ripping it.
-    </_p>
-    <_p>
+    </p>
+    <p>
       Sound Juicer is designed to be easy to use, and to work with little user
       intervention.
       When you start Sound Juicer, it will examine the CD in the drive and try
       to locate information about the audio tracks using the freely-available
       MusicBrainz service.
-    </_p>
+    </p>
   </description>
   <url type="homepage">https://wiki.gnome.org/Apps/SoundJuicer</url>
   <url type="bugtracker">https://bugzilla.gnome.org/enter_bug.cgi?product=sound-juicer</url>
diff --git a/data/sound-juicer.desktop.in.in b/data/sound-juicer.desktop.in.in
index 3556cb0..98063a0 100644
--- a/data/sound-juicer.desktop.in.in
+++ b/data/sound-juicer.desktop.in.in
@@ -1,9 +1,9 @@
 [Desktop Entry]
-_Name=Sound Juicer
-_GenericName=Audio CD Extractor
-_X-GNOME-FullName=Sound Juicer Audio CD Extractor
-_Comment=Copy music from your CDs
-_Keywords=Ripper;
+Name=Sound Juicer
+GenericName=Audio CD Extractor
+X-GNOME-FullName=Sound Juicer Audio CD Extractor
+Comment=Copy music from your CDs
+Keywords=Ripper;
 Exec=sound-juicer %u
 Icon=sound-juicer
 StartupNotify=true
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..06fd6fe
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,124 @@
+# 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.
+# The --flag options cover everything in glib and gio apart from g_log
+# or g_test family of functions as their messages are not expected to
+# be translated.
+XGETTEXT_OPTIONS = --from-code=UTF-8                                  \
+               --keyword=_               --keyword=N_                \
+               --keyword=C_:1c,2         --keyword=NC_:1c,2          \
+               --keyword=g_dngettext:2,3                             \
+               --flag=g_application_command_line_print:2:c-format    \
+               --flag=g_application_command_line_printerr:2:c-format \
+               --flag=g_dbus_error_set_dbus_error:4:c-format         \
+               --flag=g_dbus_error_set_dbus_error_valist:4:c-format  \
+               --flag=g_dbus_method_invocation_return_error:4:c-format \
+               --flag=g_dbus_method_invocation_return_error_valist:4:c-format \
+               --flag=g_error_new:3:c-format                         \
+               --flag=g_error_new_valist:3:c-format                  \
+               --flag=g_fprintf:2:c-format                           \
+               --flag=g_markup_printf_escaped:1:c-format             \
+               --flag=g_markup_vprintf_escaped:1:c-format            \
+               --flag=g_output_stream_printf:5:c-format              \
+               --flag=g_output_stream_vprintf:5:c-format             \
+               --flag=g_prefix_error:2:c-format                      \
+               --flag=g_printf:1:c-format                            \
+               --flag=g_printf_string_upper_bound:1:c-format         \
+               --flag=g_propagate_prefixed_error:3:c-format          \
+               --flag=g_set_error:4:c-format                         \
+               --flag=g_simple_async_report_error_in_idle:6:c-format \
+               --flag=g_simple_async_result_new_error:6:c-format     \
+               --flag=g_simple_async_result_set_error:4:c-format     \
+               --flag=g_simple_async_result_set_error_va:4:c-format  \
+               --flag=g_snprintf:3:c-format                          \
+               --flag=g_sprintf:2:c-format                           \
+               --flag=g_strdup_printf:1:c-format                     \
+               --flag=g_strdup_vprintf:1:c-format                    \
+               --flag=g_string_append_printf:2:c-format              \
+               --flag=g_string_append_vprintf:2:c-format             \
+               --flag=g_string_printf:2:c-format                     \
+               --flag=g_string_sprintf:2:c-format                    \
+               --flag=g_string_sprintfa:2:c-format                   \
+               --flag=g_string_vprintf:2:c-format                    \
+               --flag=g_task_report_error_new:7:c-format             \
+               --flag=g_task_return_new_error:4:c-format             \
+               --flag=g_variant_new_printf:1:c-format                \
+               --flag=g_vasprintf:2:c-format                         \
+               --flag=g_vfprintf:2:c-format                          \
+               --flag=g_vprintf:1:c-format                           \
+               --flag=g_vsnprintf:3:c-format                         \
+               --flag=g_vsprintf: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 =
+
+# 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=sound-juicer
+
+# 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 = --previous --quiet
+
+# 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 44d1a1c..521bacd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,12 +1,11 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
-[encoding: UTF-8]
-[type: gettext/gsettings]data/org.gnome.sound-juicer.gschema.xml
+data/org.gnome.sound-juicer.gschema.xml
 data/sound-juicer.desktop.in.in
 data/appdata/sound-juicer.appdata.xml.in
-[type: gettext/glade]data/sound-juicer.ui
-[type: gettext/glade]data/sound-juicer-menu.ui
-[type: gettext/glade]data/sound-juicer-shortcuts.ui
+data/sound-juicer.ui
+data/sound-juicer-menu.ui
+data/sound-juicer-shortcuts.ui
 libjuicer/sj-error.c
 libjuicer/sj-extractor.c
 libjuicer/sj-metadata.c
diff --git a/src/sj-main.c b/src/sj-main.c
index a4aa0ed..2221e2b 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -2546,16 +2546,16 @@ int main (int argc, char **argv)
   };
   guint status = 0;
 
-  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  textdomain (GETTEXT_PACKAGE);
+  bindtextdomain (PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (PACKAGE, "UTF-8");
+  textdomain (PACKAGE);
 
   g_set_application_name (_("Sound Juicer"));
   g_setenv ("PULSE_PROP_media.role", "music", TRUE);
 
   ctx = g_option_context_new (N_("- Extract music from your CDs"));
-  g_option_context_add_main_entries (ctx, entries, GETTEXT_PACKAGE);
-  g_option_context_set_translation_domain(ctx, GETTEXT_PACKAGE);
+  g_option_context_add_main_entries (ctx, entries, PACKAGE);
+  g_option_context_set_translation_domain(ctx, PACKAGE);
   g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
   g_option_context_add_group (ctx, gst_init_get_option_group ());
   g_option_context_add_group (ctx, brasero_media_get_option_group ());


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