>From 93a8464a7fc68ab8f3d24276f51d3ae280c6886f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= Date: Wed, 20 Mar 2013 19:59:10 +0100 Subject: [PATCH 3/4] Test GtkBuilder UI files extraction support. --- gettext-tools/tests/ChangeLog | 9 + gettext-tools/tests/Makefile.am | 3 +- gettext-tools/tests/xgettext-gtkbuilder-1 | 70 ++++++ gettext-tools/tests/xgettext-gtkbuilder-2 | 272 ++++++++++++++++++++++ gettext-tools/tests/xgettext-gtkbuilder-empty.ui | 4 + 5 files changed, 357 insertions(+), 1 deletion(-) create mode 100755 gettext-tools/tests/xgettext-gtkbuilder-1 create mode 100755 gettext-tools/tests/xgettext-gtkbuilder-2 create mode 100644 gettext-tools/tests/xgettext-gtkbuilder-empty.ui diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index a8c85f0..d44c3c5 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,12 @@ +2013-03-20 Miguel Angel Arruga Vivas + + 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-03-03 Miguel Angel Arruga Vivas Add a test case for atkproperty tag in Glade2 files. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index e66185e..81263be 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 \ @@ -140,7 +141,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 0000000..7163d51 --- /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 < xg-gtk-1.ui + + + + + False + This is an empty window + + + + + +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 < 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 , 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 \n" +"Language-Team: LANGUAGE \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 0000000..ff78592 --- /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 < xg-gtk-2.ui + + + + + True + False + gtk-about + + + True + False + gtk-help + + + True + False + gtk-connect + + + + + + + + + + + + + Hi + Comment + 999 + + + Hello + Translatable comment. + 88 + + + Oi + Please... + 86855555 + + + + + False + + + True + False + vertical + + + True + False + + + False + True + False + One thing + True + + + True + False + + + One thing + False + True + False + image1 + False + + + + + + + + + False + True + False + H_elp + True + + + True + False + + + One thing + False + True + False + image2 + False + + + + + Greetings + False + True + False + image3 + False + + + + + + + + + False + True + 0 + + + + + True + True + liststore + + + + + + + True + True + 1 + + + + + One thing + False + True + True + True + False + + + False + True + 2 + + + + + + +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 , 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 \n" +"Language-Team: LANGUAGE \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 0000000..a47d1bd --- /dev/null +++ b/gettext-tools/tests/xgettext-gtkbuilder-empty.ui @@ -0,0 +1,4 @@ + + + + -- 1.7.10.4