[hitori] build: Port from intltool to upstream gettext



commit 2072139e48a418b37374a70a23aded3f47792dbf
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Jun 11 19:18:51 2015 +0100

    build: Port from intltool to upstream gettext
    
    Since version 0.19.8, gettext has supported everything we need for
    localisation, and in an architecturally nicer way than intltool. Port to
    it and drop the horrendous XML hacks from our AppData file.
    
    This drops the dependency on intltool and adds a dependency on gettext
    0.19.8.

 Makefile.am                          |   23 ++++-------
 autogen.sh                           |    1 -
 configure.ac                         |    6 +--
 data/org.gnome.Hitori.appdata.xml.in |   10 ++--
 data/org.gnome.Hitori.desktop.in     |    6 +-
 po/Makevars                          |   68 ++++++++++++++++++++++++++++++++++
 po/POTFILES.in                       |    5 +-
 src/interface.c                      |    2 +-
 src/main.c                           |   10 ++--
 9 files changed, 94 insertions(+), 37 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 749bf6e..7da5fad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,9 +102,10 @@ gsettings_SCHEMAS = data/org.gnome.hitori.gschema.xml
 @GSETTINGS_RULES@
 
 # Desktop file
-# We can't use INTLTOOL_DESKTOP_RULE here due to lp#605826
 %.desktop: %.desktop.in
-       $(MKDIR_P) $(dir $@); LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache 
$(top_srcdir)/po $< $@
+       @$(MKDIR_P) $(dir $@)
+       $(AM_V_GEN) $(MSGFMT) --desktop --template $< -o $@-t \
+         -d $(top_srcdir)/po && mv $@-t $@
 
 desktop_in_files = data/org.gnome.Hitori.desktop.in
 desktopdir = $(datadir)/applications
@@ -118,7 +119,6 @@ CLEANFILES += $(desktop_DATA)
 
 # AppData
 @APPSTREAM_XML_RULES@
-@INTLTOOL_XML_RULE@
 
 appstream_in_files = data/org.gnome.Hitori.appdata.xml.in
 appstream_XML = $(appstream_in_files:.appdata.xml.in=.appdata.xml)
@@ -126,12 +126,14 @@ appstream_XML = $(appstream_in_files:.appdata.xml.in=.appdata.xml)
 EXTRA_DIST += $(appstream_in_files)
 CLEANFILES += $(appstream_XML)
 
+%.appdata.xml: %.appdata.xml.in
+       @$(MKDIR_P) $(dir $@)
+       $(AM_V_GEN) $(MSGFMT) --xml --template $< -o $@-t \
+         -d $(top_srcdir)/po && mv $@-t $@
+
 # Gubbins
 EXTRA_DIST += \
        autogen.sh \
-       intltool-extract.in \
-       intltool-merge.in \
-       intltool-update.in \
        README \
        COPYING \
        COPYING-DOCS \
@@ -144,12 +146,6 @@ EXTRA_DIST += \
        hitori.doap \
        $(NULL)
 
-DISTCLEANFILES = \
-       intltool-extract \
-       intltool-merge \
-       intltool-update \
-       $(NULL)
-
 MAINTAINERCLEANFILES = \
        $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \
        $(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN) \
@@ -158,9 +154,6 @@ MAINTAINERCLEANFILES = \
        compile \
        config.h.in \
        config.rpath \
-       intltool-extract.in \
-       intltool-merge.in \
-       intltool-update.in \
        `find "m4" -type f -name "*.m4" -print` \
        po/Makevars.template \
        po/Rules-quot \
diff --git a/autogen.sh b/autogen.sh
index a9736b4..cf4b3a9 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -33,7 +33,6 @@ if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then
 fi
 
 aclocal --install || exit 1
-intltoolize --force --copy --automake || exit 1
 autoreconf --verbose --force --install || exit 1
 
 cd "$olddir"
diff --git a/configure.ac b/configure.ac
index b40c66b..69fc9d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,10 +25,8 @@ AX_CODE_COVERAGE()
 AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources])
 
 # Internationalisation
-GETTEXT_PACKAGE=hitori
-AC_SUBST([GETTEXT_PACKAGE])
-AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext package name])
-IT_PROG_INTLTOOL([0.50.2])
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.19.8])
 
 # GSettings
 GLIB_GSETTINGS
diff --git a/data/org.gnome.Hitori.appdata.xml.in b/data/org.gnome.Hitori.appdata.xml.in
index fa4f6dc..152839e 100644
--- a/data/org.gnome.Hitori.appdata.xml.in
+++ b/data/org.gnome.Hitori.appdata.xml.in
@@ -6,21 +6,21 @@
   <project_license>GPL-3.0+ and CC-BY-SA-3.0</project_license>
 
   <!-- Translators: the name of the application as it appears in a software center -->
-  <_name>GNOME Hitori</_name>
+  <name>GNOME Hitori</name>
 
   <!-- Translators: the brief summary of the application as it appears in a software center. -->
-  <_summary>Play the Hitori puzzle game</_summary>
+  <summary>Play the Hitori puzzle game</summary>
   <description>
 
     <!-- Translators: These are the application description paragraphs in the AppData file. -->
-    <_p>Hitori is a logic game similar to the popular game of Sudoku.</_p>
-    <_p>
+    <p>Hitori is a logic game similar to the popular game of Sudoku.</p>
+    <p>
       You play the game against the clock, aiming to eliminate all the duplicate
       numbers in each row and column in the fastest time.
       Multiple sizes of game board are supported, and you can place markers on
       cells to help work out the solution.
       If you get stuck, the game can give you a hint.
-    </_p>
+    </p>
   </description>
   <screenshots>
     <screenshot type="default" width="400" height="480">
diff --git a/data/org.gnome.Hitori.desktop.in b/data/org.gnome.Hitori.desktop.in
index a9af9db..62b43f1 100644
--- a/data/org.gnome.Hitori.desktop.in
+++ b/data/org.gnome.Hitori.desktop.in
@@ -1,8 +1,8 @@
 [Desktop Entry]
-_Name=Hitori
-_Comment=Play the Hitori puzzle game
+Name=Hitori
+Comment=Play the Hitori puzzle game
 # Translators: Search terms to find this application. Do NOT translate or localise the semicolons! The list 
MUST also end with a semicolon!
-_Keywords=puzzle;game;logic;grid;
+Keywords=puzzle;game;logic;grid;
 Exec=hitori
 Icon=org.gnome.Hitori
 Terminal=false
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..b90d427
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,68 @@
+# 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=_ --flag=_:1:pass-c-format \
+  --keyword=N_ --flag=N_:1:pass-c-format \
+  --flag=g_log:3:c-format --flag=g_logv:3:c-format \
+  --flag=g_error:1:c-format --flag=g_message:1:c-format \
+  --flag=g_critical:1:c-format --flag=g_warning:1:c-format \
+  --flag=g_print:1:c-format \
+  --flag=g_printerr:1:c-format \
+  --flag=g_strdup_printf:1:c-format --flag=g_strdup_vprintf:1:c-format \
+  --flag=g_printf_string_upper_bound:1:c-format \
+  --flag=g_snprintf:3:c-format --flag=g_vsnprintf:3:c-format \
+  --flag=g_string_sprintf:2:c-format \
+  --flag=g_string_sprintfa:2:c-format \
+  --flag=g_scanner_error:2:c-format \
+  --flag=g_scanner_warn: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 = $(PACKAGE_STRING) authors
+
+# 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 = $(PACKAGE_BUGREPORT)
+
+# 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 = --quiet
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f1b6229..cf446cc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,9 +1,8 @@
 # List of source files containing translatable strings.
-[encoding: UTF-8]
 data/org.gnome.Hitori.desktop.in
 data/org.gnome.Hitori.appdata.xml.in
-[type: gettext/glade]data/hitori-menus.ui
-[type: gettext/glade]data/hitori.ui
+data/hitori-menus.ui
+data/hitori.ui
 data/org.gnome.hitori.gschema.xml
 src/interface.c
 src/main.c
diff --git a/src/interface.c b/src/interface.c
index 510974f..795d5d5 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -75,7 +75,7 @@ hitori_create_interface (Hitori *hitori)
 
        builder = gtk_builder_new_from_resource ("/org/gnome/Hitori/ui/hitori.ui");
 
-       gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
+       gtk_builder_set_translation_domain (builder, PACKAGE);
        gtk_builder_connect_signals (builder, hitori);
 
        /* Setup the main window */
diff --git a/src/main.c b/src/main.c
index d41dcc4..53807f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -94,9 +94,9 @@ constructed (GObject *object)
        g_application_set_flags (G_APPLICATION (object), G_APPLICATION_HANDLES_COMMAND_LINE);
 
        /* Localisation */
-       bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
-       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-       textdomain (GETTEXT_PACKAGE);
+       bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
+       bind_textdomain_codeset (PACKAGE, "UTF-8");
+       textdomain (PACKAGE);
 
        g_set_application_name (_("Hitori"));
        gtk_window_set_default_icon_name ("org.gnome.Hitori");
@@ -223,8 +223,8 @@ handle_command_line (GApplication *application, GApplicationCommandLine *command
 
        /* Options */
        context = g_option_context_new (_("- Play a game of Hitori"));
-       g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
-       g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+       g_option_context_set_translation_domain (context, PACKAGE);
+       g_option_context_add_main_entries (context, options, PACKAGE);
 
        if (g_option_context_parse (context, &argc, &argv, &error) == TRUE) {
                /* Activate the remote instance */


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