]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add support for Glade 2.
authorBruno Haible <bruno@clisp.org>
Tue, 27 May 2003 11:11:06 +0000 (11:11 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:38 +0000 (12:10 +0200)
NEWS
gettext-tools/doc/ChangeLog
gettext-tools/doc/gettext.texi
gettext-tools/src/ChangeLog
gettext-tools/src/x-glade.c
gettext-tools/src/x-glade.h
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-25 [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 505d602d86635b866bde39dbd91403d973edd8fb..ee984e3aeb025f2bd1be28f524854b76171d9d34 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+Version 0.12.2 - XXX 2003
+
+* Data formats support:
+
+  - Glade:
+    xgettext now also supports Glade version 2.
+\f
 Version 0.12.1 - May 2003
 
 * Bug fixes.
index fa54bd3bd849876f381ca33e207a98c75061c8fa..d38b7a133d82057e086ed6f041a94550b2fc6c46 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-24  Bruno Haible  <bruno@clisp.org>
+
+       * gettext.texi (Glade): Mention support og Glade 2.
+
 2003-05-22  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.12.1 released.
index 36d9d3870bb6ce69edd0b660be10d66e9954ed59..68ca8888c43612143b2357c8deb942b963fb5d4b 100644 (file)
@@ -8448,13 +8448,13 @@ fpk
 
 @table @asis
 @item RPMs
-glade, libglade, xml-i18n-tools
+glade, libglade, glade2, libglade2, intltool
 
 @item File extension
-@code{glade}
+@code{glade}, @code{glade2}
 
 @item Extractor
-@code{xgettext}, @code{libglade-xgettext}
+@code{xgettext}, @code{libglade-xgettext}, @code{xml-i18n-extract}, @code{intltool-extract}
 @end table
 
 @c This is the template for new data formats.
index 804f45f1aed926cd7a3a3ab0c558e292bb77a6a6..e4e9ec64ff7befd065f25eb70531efcccc056565 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-24  Bruno Haible  <bruno@clisp.org>
+
+       * x-glade.h (EXTENSIONS_GLADE): Also recognize the .glade2 extension.
+       * x-glade.c (start_element_handler): Also extract strings according to
+       Glade 2 conventions.
+
 2003-05-22  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.12.1 released.
index 3ba11cb88e7e6475c21f847d7995ed0c622d9ad8..92d20c267fb7da4425155b14170153e52ae7606d 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext glade backend.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
@@ -232,8 +232,49 @@ start_element_handler (void *userData, const char *name,
   stack[stack_depth - 1].extract_string = false;
 
   p = &stack[stack_depth];
+  /* In Glade 1, a few specific elements are translatable.  */
   p->extract_string =
     (find_entry (&keywords, name, strlen (name), &hash_result) == 0);
+  /* In Glade 2, all <property> and <atkproperty> elements are translatable
+     that have the attribute translatable="yes".  */
+  if (!p->extract_string
+      && (strcmp (name, "property") == 0 || strcmp (name, "atkproperty") == 0))
+    {
+      bool has_translatable = false;
+      const char **attp = attributes;
+      while (*attp != NULL)
+       {
+         if (strcmp (attp[0], "translatable") == 0)
+           {
+             has_translatable = (strcmp (attp[1], "yes") == 0);
+             break;
+           }
+         attp += 2;
+       }
+      p->extract_string = has_translatable;
+    }
+  if (!p->extract_string
+      && strcmp (name, "atkaction") == 0)
+    {
+      const char **attp = attributes;
+      while (*attp != NULL)
+       {
+         if (strcmp (attp[0], "description") == 0)
+           {
+             if (strcmp (attp[1], "") != 0)
+               {
+                 lex_pos_ty pos;
+
+                 pos.file_name = logical_file_name;
+                 pos.line_number = XML_GetCurrentLineNumber (parser);
+
+                 remember_a_message (mlp, xstrdup (attp[1]), &pos);
+               }
+             break;
+           }
+         attp += 2;
+       }
+    }
   p->lineno = XML_GetCurrentLineNumber (parser);
   p->buffer = NULL;
   p->bufmax = 0;
index db6ae6f07cd9b31eedde7a788874eca8cad37aa0..0e750ff8fa4f0d40c375c0e60338af4034f3baf8 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext glade backend.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
    This program is free software; you can redistribute it and/or modify
@@ -19,6 +19,7 @@
 
 #define EXTENSIONS_GLADE \
   { "glade",     "glade"    },                                         \
+  { "glade2",    "glade"    },                                         \
 
 #define SCANNERS_GLADE \
   { "glade",      extract_glade, NULL },                               \
index 7c663f3290443e4b3f006bf64a11c338e7daea39..77aaed607d06798b0240fb9da128bb40d0f8fd50 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-24  Bruno Haible  <bruno@clisp.org>
+
+       * xgettext-25: New file.
+       * Makefile.am (TESTS): Add it.
+
 2003-05-22  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.12.1 released.
index 01887a20bcf17ce78db7567d8972c559db2980b6..60269933442af391104da7749d4744609a4e7f3b 100644 (file)
@@ -49,7 +49,7 @@ TESTS = gettext-1 gettext-2 \
        xgettext-7 xgettext-8 xgettext-9 xgettext-10 xgettext-11 xgettext-12 \
        xgettext-13 xgettext-14 xgettext-15 xgettext-16 xgettext-17 \
        xgettext-18 xgettext-19 xgettext-20 xgettext-21 xgettext-22 \
-       xgettext-23 xgettext-24 \
+       xgettext-23 xgettext-24 xgettext-25 \
        format-awk-1 format-awk-2 \
        format-c-1 format-c-2 format-c-3 format-c-4 \
        format-elisp-1 format-elisp-2 \
diff --git a/gettext-tools/tests/xgettext-25 b/gettext-tools/tests/xgettext-25
new file mode 100755 (executable)
index 0000000..abc096e
--- /dev/null
@@ -0,0 +1,202 @@
+#!/bin/sh
+
+# Test of Glade 2 support.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles asciitable.glade2"
+cat <<EOF > asciitable.glade2
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" >
+
+<glade-interface>
+  <widget class="GtkDialog" id="dialog">
+    <property name="visible">no</property>
+    <property name="title" translatable="yes">gedit: ASCII table</property>
+    <property name="type">GTK_WINDOW_TOPLEVEL</property>
+    <property name="modal">no</property>
+    <property name="allow_shrink">yes</property>
+    <property name="allow_grow">yes</property>
+    <property name="window-position">GTK_WIN_POS_NONE</property>
+
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="homogeneous">no</property>
+        <property name="spacing">8</property>
+        <property name="visible">yes</property>
+
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="spacing">8</property>
+            <property name="visible">yes</property>
+
+            <child>
+              <widget class="GtkButton" id="insert_char_button">
+                <property name="can_default">yes</property>
+                <property name="can_focus">yes</property>
+                <property name="label" translatable="yes">Insert char</property>
+                <property name="visible">yes</property>
+              </widget>
+            </child>
+
+            <child>
+              <widget class="GtkButton" id="close_button">
+                <property name="can_default">yes</property>
+                <property name="can_focus">yes</property>
+                <property name="visible">yes</property>
+                <property name="label">gtk-close</property>
+                <property name="use_stock">yes</property>
+                <property name="use_underline">yes</property>
+              </widget>
+            </child>
+
+            <child>
+              <widget class="GtkButton" id="help_button">
+                <property name="can_default">yes</property>
+                <property name="can_focus">yes</property>
+                <property name="visible">yes</property>
+                <property name="label">gtk-help</property>
+                <property name="use_stock">yes</property>
+                <property name="use_underline">yes</property>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="padding">0</property>
+            <property name="expand">no</property>
+            <property name="fill">yes</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+
+        <child>
+          <widget class="GtkVBox" id="asciitable_dialog_content">
+            <property name="border_width">6</property>
+            <property name="homogeneous">no</property>
+            <property name="spacing">8</property>
+            <property name="visible">yes</property>
+
+            <child>
+              <widget class="GtkLabel" id="label1">
+                <property name="label" translatable="yes">If you wish to insert any of the characters in to the active 
+document, select the character and click the &quot;Insert Char&quot; 
+button or double click the character in the table.</property>
+                <property name="justify">GTK_JUSTIFY_LEFT</property>
+                <property name="wrap">no</property>
+                <property name="xalign">0.0</property>
+                <property name="yalign">0.5</property>
+                <property name="xpad">0</property>
+                <property name="ypad">0</property>
+                <property name="visible">yes</property>
+              </widget>
+              <packing>
+                <property name="padding">0</property>
+                <property name="expand">no</property>
+                <property name="fill">no</property>
+              </packing>
+            </child>
+
+            <child>
+              <widget class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="shadow_type">GTK_SHADOW_IN</property>
+                <property name="height-request">350</property>
+                <property name="visible">yes</property>
+
+                <child>
+                  <widget class="GtkTreeView" id="ascii_table">
+                    <property name="can_focus">yes</property>
+                    <property name="headers-visible">yes</property>
+                    <property name="visible">yes</property>
+                  </widget>
+                </child>
+
+                <child internal-child="hscrollbar">
+                  <widget class="GtkHScrollbar" id="convertwidget1">
+                    <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
+                    <property name="visible">yes</property>
+                  </widget>
+                </child>
+
+                <child internal-child="vscrollbar">
+                  <widget class="GtkVScrollbar" id="convertwidget2">
+                    <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
+                    <property name="visible">yes</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="padding">0</property>
+                <property name="expand">yes</property>
+                <property name="fill">yes</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="padding">0</property>
+            <property name="expand">yes</property>
+            <property name="fill">yes</property>
+          </packing>
+        </child>
+      </widget>
+      <packing>
+        <property name="padding">4</property>
+        <property name="expand">yes</property>
+        <property name="fill">yes</property>
+      </packing>
+    </child>
+  </widget>
+</glade-interface>
+EOF
+
+tmpfiles="$tmpfiles xg-test25.tmp xg-test25.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o xg-test25.tmp asciitable.glade2 
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+grep -v 'POT-Creation-Date' < xg-test25.tmp > xg-test25.pot
+
+tmpfiles="$tmpfiles xg-test25.ok"
+cat <<EOF > xg-test25.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"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: asciitable.glade2:7
+msgid "gedit: ASCII table"
+msgstr ""
+
+#: asciitable.glade2:30
+msgid "Insert char"
+msgstr ""
+
+#: asciitable.glade2:74
+msgid ""
+"If you wish to insert any of the characters in to the active \n"
+"document, select the character and click the \"Insert Char\" \n"
+"button or double click the character in the table."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-test25.ok xg-test25.pot
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result