[gnome-builder/wip/tingping/gstyle-translations] Handle gstyle translations



commit 0261e9e52b2b5aaf393f4ecf632add94122a4329
Author: Patrick Griffis <tingping tingping se>
Date:   Thu Jul 21 20:14:34 2016 -0400

    Handle gstyle translations

 configure.ac                                       |    2 +-
 contrib/gstyle/Makefile.am                         |    5 +++++
 contrib/gstyle/data/its/gstyle.its                 |    4 ++++
 contrib/gstyle/data/its/gstyle.loc                 |    6 ++++++
 .../palette.xml => data/palettes/basic.gstyle.xml} |    2 +-
 contrib/gstyle/gstyle-palette.c                    |    4 ++--
 .../basic.xml => tests/data/palette.gstyle.xml}    |    0
 plugins/color-picker/Makefile.am                   |    9 +++++++++
 .../data/{basic.xml => basic.gstyle.xml.in}        |    2 +-
 .../color-picker/gb-color-picker-workbench-addin.c |    2 +-
 plugins/color-picker/gb-color-picker.gresource.xml |    2 +-
 po/Makevars                                        |    5 ++++-
 po/POTFILES.in                                     |    4 +---
 po/POTFILES.skip                                   |    2 ++
 14 files changed, 38 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ebe62c4..c896021 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,7 @@ dnl ***********************************************************************
 GETTEXT_PACKAGE=AC_PACKAGE_TARNAME
 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [GETTEXT package name])
 AC_SUBST(GETTEXT_PACKAGE)
-AM_GNU_GETTEXT_VERSION([0.19.7])
+AM_GNU_GETTEXT_VERSION([0.19.8])
 AM_GNU_GETTEXT([external])
 
 
diff --git a/contrib/gstyle/Makefile.am b/contrib/gstyle/Makefile.am
index c7a8f5d..b8f6903 100644
--- a/contrib/gstyle/Makefile.am
+++ b/contrib/gstyle/Makefile.am
@@ -8,6 +8,11 @@ SUBDIRS = . tests
 pkglibdir = $(libdir)/gnome-builder
 pkglib_LTLIBRARIES = libgstyle-private.la
 
+#gettextitsdir = $(datadir)/gettext/its
+noinst_DATA =                    \
+       data/its/gstyle.its      \
+       data/its/gstyle.loc
+
 headersdir = $(includedir)/gnome-builder-@VERSION@/gstyle
 headers_DATA =                        \
        gstyle-animation.h            \
diff --git a/contrib/gstyle/data/its/gstyle.its b/contrib/gstyle/data/its/gstyle.its
new file mode 100644
index 0000000..b493ad9
--- /dev/null
+++ b/contrib/gstyle/data/its/gstyle.its
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<its:rules xmlns:its="http://www.w3.org/2005/11/its"; version="1.0">
+  <its:translateRule selector="//palette/@name" translate="yes"/>
+</its:rules>
diff --git a/contrib/gstyle/data/its/gstyle.loc b/contrib/gstyle/data/its/gstyle.loc
new file mode 100644
index 0000000..f742495
--- /dev/null
+++ b/contrib/gstyle/data/its/gstyle.loc
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<locatingRules>
+  <locatingRule name="GStyle" pattern="*.gstyle.xml">
+    <documentRule localName="palette" target="gstyle.its"/>
+  </locatingRule>
+</locatingRules>
diff --git a/contrib/gstyle/tests/data/palette.xml b/contrib/gstyle/data/palettes/basic.gstyle.xml
similarity index 97%
rename from contrib/gstyle/tests/data/palette.xml
rename to contrib/gstyle/data/palettes/basic.gstyle.xml
index f62c42d..f5a33eb 100644
--- a/contrib/gstyle/tests/data/palette.xml
+++ b/contrib/gstyle/data/palettes/basic.gstyle.xml
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 -->
-<palette id="basic" _name="Basic">
+<palette id="basic" name="Basic">
 
   <color name="color_hex6"           value="#808080"/>
   <color name="color_hex3"           value="#1aF"/>
diff --git a/contrib/gstyle/gstyle-palette.c b/contrib/gstyle/gstyle-palette.c
index 0a927d0..7f615f4 100644
--- a/contrib/gstyle/gstyle-palette.c
+++ b/contrib/gstyle/gstyle-palette.c
@@ -103,7 +103,7 @@ gstyle_palette_xml_get_header (xmlTextReaderPtr   reader,
       xmlTextReaderDepth (reader) == 0)
     {
       *id = strdup_and_xmlfree (xmlTextReaderGetAttribute (reader, CHAR_TO_XML ("id")));
-      *name = strdup_and_xmlfree (xmlTextReaderGetAttribute (reader, CHAR_TO_XML ("_name")));
+      *name = strdup_and_xmlfree (xmlTextReaderGetAttribute (reader, CHAR_TO_XML ("name")));
       if (gstyle_str_empty0 (*id) || gstyle_utf8_is_spaces (*id))
         {
           g_warning ("Palette '%s'has an empty or NULL id\n", *name);
@@ -873,7 +873,7 @@ gstyle_palette_save_to_xml (GstylePalette  *self,
   id = gstyle_palette_get_id (self);
   name = gstyle_palette_get_name (self);
   xmlNewProp (palette_node, CHAR_TO_XML ("id"), CHAR_TO_XML (id));
-  xmlNewProp (palette_node, CHAR_TO_XML ("_name"), CHAR_TO_XML (name));
+  xmlNewProp (palette_node, CHAR_TO_XML ("name"), CHAR_TO_XML (name));
 
   n_colors = gstyle_palette_get_len (self);
   for (gint i = 0; i < n_colors; ++i)
diff --git a/contrib/gstyle/data/palettes/basic.xml b/contrib/gstyle/tests/data/palette.gstyle.xml
similarity index 100%
rename from contrib/gstyle/data/palettes/basic.xml
rename to contrib/gstyle/tests/data/palette.gstyle.xml
diff --git a/plugins/color-picker/Makefile.am b/plugins/color-picker/Makefile.am
index f5c77ef..0804166 100644
--- a/plugins/color-picker/Makefile.am
+++ b/plugins/color-picker/Makefile.am
@@ -46,6 +46,15 @@ libcolor_picker_plugin_la_LIBADD = \
 
 libcolor_picker_plugin_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 
+gstyle_in_files = data/basic.gstyle.xml.in
+noinst_DATA = $(gstyle_in_files:.gstyle.xml.in=.gstyle.xml)
+BUILT_SOURCES += $(noinst_DATA)
+EXTRA_DIST += $(gstyle_in_files)
+
+%.gstyle.xml: %.gstyle.xml.in
+       $(AM_V_GEN)env GETTEXTDATADIRS="$(top_srcdir)/contrib/gstyle/data" \
+               $(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
+
 glib_resources_c = gb-color-picker-resources.c
 glib_resources_h = gb-color-picker-resources.h
 glib_resources_xml = gb-color-picker.gresource.xml
diff --git a/plugins/color-picker/data/basic.xml b/plugins/color-picker/data/basic.gstyle.xml.in
similarity index 97%
rename from plugins/color-picker/data/basic.xml
rename to plugins/color-picker/data/basic.gstyle.xml.in
index f62c42d..f5a33eb 100644
--- a/plugins/color-picker/data/basic.xml
+++ b/plugins/color-picker/data/basic.gstyle.xml.in
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 -->
-<palette id="basic" _name="Basic">
+<palette id="basic" name="Basic">
 
   <color name="color_hex6"           value="#808080"/>
   <color name="color_hex3"           value="#1aF"/>
diff --git a/plugins/color-picker/gb-color-picker-workbench-addin.c 
b/plugins/color-picker/gb-color-picker-workbench-addin.c
index 89078a2..a9c4644 100644
--- a/plugins/color-picker/gb-color-picker-workbench-addin.c
+++ b/plugins/color-picker/gb-color-picker-workbench-addin.c
@@ -83,7 +83,7 @@ init_palettes (GbColorPickerWorkbenchAddin *self)
   g_assert (GB_IS_COLOR_PICKER_WORKBENCH_ADDIN (self));
 
   palette_widget = gstyle_color_panel_get_palette_widget (GSTYLE_COLOR_PANEL (self->color_panel));
-  add_palette (self, palette_widget, 
"resource:///org/gnome/builder/plugins/color-picker-plugin/data/basic.xml");
+  add_palette (self, palette_widget, 
"resource:///org/gnome/builder/plugins/color-picker-plugin/data/basic.gstyle.xml");
   palette = add_palette (self, palette_widget, 
"resource:///org/gnome/builder/plugins/color-picker-plugin/data/svg.gpl");
 
   gstyle_color_panel_show_palette (GSTYLE_COLOR_PANEL (self->color_panel), palette);
diff --git a/plugins/color-picker/gb-color-picker.gresource.xml 
b/plugins/color-picker/gb-color-picker.gresource.xml
index 4a50652..9a1c6bf 100644
--- a/plugins/color-picker/gb-color-picker.gresource.xml
+++ b/plugins/color-picker/gb-color-picker.gresource.xml
@@ -13,7 +13,7 @@
     <file>gtk/color-picker-palette-menu.ui</file>
     <file>gtk/menus.ui</file>
 
-    <file>data/basic.xml</file>
+    <file>data/basic.gstyle.xml</file>
     <file>data/svg.gpl</file>
 
     <file compressed="true" 
alias="icons/scalable/actions/builder-colorpicker-load-palette.svg">icons/palette/load-palette.svg</file>
diff --git a/po/Makevars b/po/Makevars
index dad02bf..336206c 100644
--- a/po/Makevars
+++ b/po/Makevars
@@ -7,8 +7,11 @@ DOMAIN = $(PACKAGE)
 subdir = po
 top_builddir = ..
 
+# This allows us using local its files
+XGETTEXT := env GETTEXTDATADIRS="$(top_builddir)/contrib/gstyle/data" $(XGETTEXT)
+
 # These options get passed to xgettext.
-XGETTEXT_OPTIONS =  --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 
--keyword=g_dngettext:2,3
+XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 
--keyword=g_dngettext:2,3
 
 # 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
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 60299fe..092ed9d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,14 +4,12 @@ contrib/egg/egg-animation.c
 contrib/egg/egg-date-time.c
 contrib/egg/egg-file-chooser-entry.c
 contrib/egg/egg-search-bar.c
-contrib/gstyle/data/palettes/basic.xml
 contrib/gstyle/gstyle-color-panel.c
 contrib/gstyle/gstyle-color-plane.c
 contrib/gstyle/gstyle-color-widget-actions.c
 contrib/gstyle/gstyle-palette.c
 contrib/gstyle/gstyle-palette-widget.c
 contrib/gstyle/tests/data/gstyle-color-editor.ui
-contrib/gstyle/tests/data/palette.xml
 contrib/gstyle/ui/gstyle-color-panel.ui
 contrib/gstyle/ui/gstyle-color-widget.ui
 contrib/gstyle/ui/gstyle-rename-popover.ui
@@ -111,7 +109,7 @@ plugins/clang/ide-clang-preferences-addin.c
 plugins/clang/ide-clang-service.c
 plugins/clang/ide-clang-symbol-node.c
 plugins/clang/ide-clang-translation-unit.c
-plugins/color-picker/data/basic.xml
+plugins/color-picker/data/basic.gstyle.xml.in
 plugins/color-picker/gb-color-picker-prefs.c
 plugins/color-picker/gb-color-picker-prefs-palette-row.c
 plugins/color-picker/gb-color-picker-workbench-addin.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index d1de359..ece41d0 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,5 +1,7 @@
 # List of source files that should *not* be translated.
 # Please keep this file sorted alphabetically.
+contrib/gstyle/data/palettes/basic.gstyle.xml
+contrib/gstyle/tests/data/palette.gstyle.xml
 contrib/tmpl/tmpl-expr-parser.c
 plugins/vala-pack/ide-vala-preferences-addin.c
 sub/plugins/vala-pack/ide-vala-preferences-addin.c


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