[gnome-builder/wip/tingping/gstyle-translations] gstyle: Add support for translations
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/tingping/gstyle-translations] gstyle: Add support for translations
- Date: Fri, 22 Jul 2016 14:17:19 +0000 (UTC)
commit b71ae9cf58d163cf7ac09d23a9f144e91e2ca518
Author: Patrick Griffis <tingping tingping se>
Date: Thu Jul 21 20:14:34 2016 -0400
gstyle: Add support for translations
configure.ac | 2 +-
contrib/gstyle/Makefile.am | 5 ++++
contrib/gstyle/check-palette.sh | 2 +-
contrib/gstyle/data/its/gstyle.its | 4 +++
contrib/gstyle/data/its/gstyle.loc | 6 +++++
.../palette.xml => data/palettes/basic.gstyle.xml} | 2 +-
contrib/gstyle/data/palettes/palette.rng | 3 ++
contrib/gstyle/gstyle-palette.c | 19 +++++++++++++++-
.../basic.xml => tests/data/palette.gstyle.xml} | 0
contrib/gstyle/tests/test-gstyle-palette.c | 2 +-
.../data/{basic.xml => basic.gstyle.xml} | 22 +++++++++----------
.../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 +
16 files changed, 58 insertions(+), 24 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/check-palette.sh b/contrib/gstyle/check-palette.sh
index 72fcdba..befb4fb 100755
--- a/contrib/gstyle/check-palette.sh
+++ b/contrib/gstyle/check-palette.sh
@@ -9,7 +9,7 @@ if [ $1 ]; then
files=$@
else
cd ./data/palettes
- files=*.xml
+ files=*.gstyle.xml
fi
for file in $files; do
diff --git a/contrib/gstyle/data/its/gstyle.its b/contrib/gstyle/data/its/gstyle.its
new file mode 100644
index 0000000..405c1eb
--- /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/data/palettes/palette.rng b/contrib/gstyle/data/palettes/palette.rng
index 6046745..dc5c5e2 100644
--- a/contrib/gstyle/data/palettes/palette.rng
+++ b/contrib/gstyle/data/palettes/palette.rng
@@ -106,6 +106,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<attribute name="_name"/>
</choice>
<optional>
+ <attribute name="gettext-domain"/>
+ </optional>
+ <optional>
<oneOrMore>
<element name="color">
<attribute name="name">
diff --git a/contrib/gstyle/gstyle-palette.c b/contrib/gstyle/gstyle-palette.c
index 0a927d0..e566c75 100644
--- a/contrib/gstyle/gstyle-palette.c
+++ b/contrib/gstyle/gstyle-palette.c
@@ -103,7 +103,22 @@ 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 (*name == NULL)
+ {
+ char *_name = strdup_and_xmlfree (xmlTextReaderGetAttribute (reader, CHAR_TO_XML ("_name")));
+ char *domain = strdup_and_xmlfree (xmlTextReaderGetAttribute (reader, CHAR_TO_XML
("gettext-domain")));
+ if (_name && domain)
+ {
+ bind_textdomain_codeset (domain, "UTF-8");
+ *name = g_strdup (g_dgettext (domain, _name));
+ g_free (_name);
+ }
+ else
+ *name = _name;
+
+ g_free (domain);
+ }
if (gstyle_str_empty0 (*id) || gstyle_utf8_is_spaces (*id))
{
g_warning ("Palette '%s'has an empty or NULL id\n", *name);
@@ -873,7 +888,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/contrib/gstyle/tests/test-gstyle-palette.c b/contrib/gstyle/tests/test-gstyle-palette.c
index 2df7078..bdf93b5 100644
--- a/contrib/gstyle/tests/test-gstyle-palette.c
+++ b/contrib/gstyle/tests/test-gstyle-palette.c
@@ -55,7 +55,7 @@ test_palette (void)
GstylePalette *palette;
printf ("\n");
- palette = load_palette ("palette.xml");
+ palette = load_palette ("palette.gstyle.xml");
g_object_unref (palette);
palette = load_palette ("palette.gpl");
diff --git a/plugins/color-picker/data/basic.xml b/plugins/color-picker/data/basic.gstyle.xml
similarity index 54%
rename from plugins/color-picker/data/basic.xml
rename to plugins/color-picker/data/basic.gstyle.xml
index f62c42d..a35302a 100644
--- a/plugins/color-picker/data/basic.xml
+++ b/plugins/color-picker/data/basic.gstyle.xml
@@ -17,16 +17,14 @@ 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">
-
- <color name="color_hex6" value="#808080"/>
- <color name="color_hex3" value="#1aF"/>
- <color name="color_rgb" value="rgb(100, 200, 50)"/>
- <color name="color_rgb_percent" value="rgb(10%, 50%, 70%)"/>
- <color name="color_rgba" value="rgba(0, 10, 70, 1)"/>
- <color name="color_rgba_percent" value="rgba(10%, 50%, 40%, 0.5)"/>
- <color name="color_hsl" value="hsl(100, 100%, 50%)"/>
- <color name="color_hsla" value="hsla(400, 50%, 40%, 0.5)"/>
- <color name="color_named" value="aliceblue"/>
-
+<palette id="basic" _name="Basic" gettext-domain="gnome-builder">
+ <color name="color_hex6" value="#808080"/>
+ <color name="color_hex3" value="#1aF"/>
+ <color name="color_rgb" value="rgb(100, 200, 50)"/>
+ <color name="color_rgb_percent" value="rgb(10%, 50%, 70%)"/>
+ <color name="color_rgba" value="rgba(0, 10, 70, 1)"/>
+ <color name="color_rgba_percent" value="rgba(10%, 50%, 40%, 0.5)"/>
+ <color name="color_hsl" value="hsl(100, 100%, 50%)"/>
+ <color name="color_hsla" value="hsla(400, 50%, 40%, 0.5)"/>
+ <color name="color_named" value="aliceblue"/>
</palette>
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..ef16586 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
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]