summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Ángel Arruga Vivas <rosen644835@gmail.com>2013-03-20 19:59:10 +0100
committerDaiki Ueno <ueno@gnu.org>2013-06-13 17:46:06 +0900
commit41abf993361d2db44d75a1ac22627e9beb587414 (patch)
treefa4b9e001f75c1603c8953918a2114a419bc0bcd
parent2c3f428a748eaa9a8cc2cc2f457ed8633e438d20 (diff)
downloadgettext-41abf993361d2db44d75a1ac22627e9beb587414.tar.gz
Test GtkBuilder UI files extraction support.
-rw-r--r--gettext-tools/tests/ChangeLog9
-rw-r--r--gettext-tools/tests/Makefile.am3
-rwxr-xr-xgettext-tools/tests/xgettext-gtkbuilder-170
-rwxr-xr-xgettext-tools/tests/xgettext-gtkbuilder-2272
-rw-r--r--gettext-tools/tests/xgettext-gtkbuilder-empty.ui4
5 files changed, 357 insertions, 1 deletions
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index 2e45223dc..85bb6c94b 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,12 @@
+2013-06-13 Miguel Angel Arruga Vivas <rosen644835@gmail.com>
+
+ Tests for GtkBuilder support.
+ * Makefile.am (TESTS): New tests xgettext-gtkbuilder{1,2}.
+ (EXTRA_DIST): Added file 'xgettext-gtkbuilder-empty.ui'.
+ * xgettext-gtkbuilder-empty.ui: New file for testing.
+ * xgettext-gtkbuilder-1: New test.
+ * xgettext-gtkbuilder-2: Likewise.
+
2013-06-06 Daiki Ueno <ueno@gnu.org>
* lang-javascript: Check if gjs gettext and format modules are
diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am
index 73290324c..89c0f708a 100644
--- a/gettext-tools/tests/Makefile.am
+++ b/gettext-tools/tests/Makefile.am
@@ -81,6 +81,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
xgettext-elisp-1 xgettext-elisp-2 \
xgettext-glade-1 xgettext-glade-2 xgettext-glade-3 xgettext-glade-4 \
xgettext-glade-5 \
+ xgettext-gtkbuilder-1 xgettext-gtkbuilder-2 \
xgettext-java-1 xgettext-java-2 xgettext-java-3 xgettext-java-4 \
xgettext-java-5 xgettext-java-6 xgettext-java-7 \
xgettext-librep-1 xgettext-librep-2 \
@@ -148,7 +149,7 @@ EXTRA_DIST += $(TESTS) \
ChangeLog.0 \
gettext-3-1.po gettext-3-2.po gettext-4.po gettext-5.po \
gettext-6-1.po gettext-6-2.po gettext-7.po \
- gettextpo-1.de.po
+ gettextpo-1.de.po xgettext-gtkbuilder-empty.ui
XGETTEXT = ../src/xgettext
diff --git a/gettext-tools/tests/xgettext-gtkbuilder-1 b/gettext-tools/tests/xgettext-gtkbuilder-1
new file mode 100755
index 000000000..7163d5112
--- /dev/null
+++ b/gettext-tools/tests/xgettext-gtkbuilder-1
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# Test of GtkBuilder support.
+# Checks that the extracted pot contains the right translatable
+# content, comments and context.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o - xgettext-gtkbuilder-empty.ui 2>/dev/null 1>&2
+test $? = 0 || {
+ echo "Skipping test: xgettext was built without GtkBuilder support"
+ rm -fr $tmpfiles; exit 77
+}
+
+tmpfiles="$tmpfiles xg-gtk-1.ui"
+cat <<EOF > xg-gtk-1.ui
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="window">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes" context="This is the context for this text" comments="This is a comment for empty window">This is an empty window</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+</interface>
+EOF
+
+tmpfiles="$tmpfiles xg-gtk-1.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o - xg-gtk-1.ui | grep -v 'POT-Creation-Date' > xg-gtk-1.pot
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-gtk-1.ok"
+cat <<EOF > xg-gtk-1.ok
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. This is a comment for empty window
+#: xg-gtk-1.ui:6
+msgctxt "This is the context for this text"
+msgid "This is an empty window"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-gtk-1.ok xg-gtk-1.pot
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
diff --git a/gettext-tools/tests/xgettext-gtkbuilder-2 b/gettext-tools/tests/xgettext-gtkbuilder-2
new file mode 100755
index 000000000..ff785924c
--- /dev/null
+++ b/gettext-tools/tests/xgettext-gtkbuilder-2
@@ -0,0 +1,272 @@
+#!/bin/sh
+
+# Test of GtkBuilder support.
+# Checks the extraction of a medium size GtkBuilder file, with
+# comments, context and translatable and not translatable content.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o - xgettext-gtkbuilder-empty.ui 2>/dev/null 1>&2
+test $? = 0 || {
+ echo "Skipping test: xgettext was built without GtkBuilder support"
+ rm -fr $tmpfiles; exit 77
+}
+
+tmpfiles="$tmpfiles xg-gtk-2.ui"
+cat <<EOF > xg-gtk-2.ui
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-about</property>
+ </object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-help</property>
+ </object>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-connect</property>
+ </object>
+ <object class="GtkListStore" id="liststore">
+ <columns>
+ <!-- column-name first column -->
+ <column type="gchararray"/>
+ <!-- column-name second column -->
+ <column type="gchararray"/>
+ <!-- column-name not extracted column -->
+ <column type="guint64"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes" context="First row">Hi</col>
+ <col id="1" translatable="yes" comments="A comment.">Comment</col>
+ <col id="2">999</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="First row">Hello</col>
+ <col id="1" translatable="yes" comments="This is no translatable.">Translatable comment.</col>
+ <col id="2">88</col>
+ </row>
+ <row>
+ <col id="0" translatable="no" context="First row" comments="Yeah">Oi</col>
+ <col id="1" translatable="yes" context="This is not translatable">Please...</col>
+ <col id="2">86855555</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkWindow" id="window">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkMenuBar" id="menubar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="menuitem1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="Menu" comments="This thing is the menu label">One thing</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem1">
+ <property name="label" translatable="yes" context="One thing" comments="This thing is the label in the inner menu.">One thing</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="image">image1</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem2">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="Menu" comments="This is easy.">H_elp</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem2">
+ <property name="label" translatable="yes" context="Second menu" comments="This one thing is for the second menu.">One thing</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="image">image2</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="imagemenuitem3">
+ <property name="label" translatable="yes" context="Second menu" comments="To you too.">Greetings</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="image">image3</property>
+ <property name="use_stock">False</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTreeView" id="treeview2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">liststore</property>
+ <signal name="columns-changed" handler="myfunction_treeview_columns_changed" object="treeview-selection2" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection2"/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button">
+ <property name="label" translatable="yes" context="Button" comments="This one thing is the button.">One thing</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
+EOF
+
+tmpfiles="$tmpfiles xg-gtk-2.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o - xg-gtk-2.ui | grep -v 'POT-Creation-Date' > xg-gtk-2.pot
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-gtk-2.ok"
+cat <<\EOF > xg-gtk-2.ok
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: xg-gtk-2.ui:30
+msgctxt "First row"
+msgid "Hi"
+msgstr ""
+
+#. A comment.
+#: xg-gtk-2.ui:31
+msgid "Comment"
+msgstr ""
+
+#: xg-gtk-2.ui:35
+msgctxt "First row"
+msgid "Hello"
+msgstr ""
+
+#. This is no translatable.
+#: xg-gtk-2.ui:36
+msgid "Translatable comment."
+msgstr ""
+
+#: xg-gtk-2.ui:41
+msgctxt "This is not translatable"
+msgid "Please..."
+msgstr ""
+
+#. This thing is the menu label
+#: xg-gtk-2.ui:62
+msgctxt "Menu"
+msgid "One thing"
+msgstr ""
+
+#. This thing is the label in the inner menu.
+#: xg-gtk-2.ui:70
+msgctxt "One thing"
+msgid "One thing"
+msgstr ""
+
+#. This is easy.
+#: xg-gtk-2.ui:87
+msgctxt "Menu"
+msgid "H_elp"
+msgstr ""
+
+#. This one thing is for the second menu.
+#: xg-gtk-2.ui:95
+msgctxt "Second menu"
+msgid "One thing"
+msgstr ""
+
+#. To you too.
+#: xg-gtk-2.ui:105
+msgctxt "Second menu"
+msgid "Greetings"
+msgstr ""
+
+#. This one thing is the button.
+#: xg-gtk-2.ui:142
+msgctxt "Button"
+msgid "One thing"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-gtk-2.ok xg-gtk-2.pot
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
diff --git a/gettext-tools/tests/xgettext-gtkbuilder-empty.ui b/gettext-tools/tests/xgettext-gtkbuilder-empty.ui
new file mode 100644
index 000000000..a47d1bd9d
--- /dev/null
+++ b/gettext-tools/tests/xgettext-gtkbuilder-empty.ui
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+</interface>