[banshee] Add tool to extract strings from addin.xml files



commit 747e2548bc68500b8ff48ab090aae64515855bff
Author: Aaron Bockover <abockover novell com>
Date:   Tue Dec 15 16:15:33 2009 -0500

    Add tool to extract strings from addin.xml files
    
    build/addin-xml-string-extract will pull out nodes from
    .addin.xml files that need to be translated and generate
    a file (data/addin-xml-strings.cs) from which intltool
    will happily extract strings into the translation catalog.

 build/Makefile.am              |    3 ++-
 build/addin-xml-string-extract |   38 ++++++++++++++++++++++++++++++++++++++
 data/Makefile.am               |   12 +++++++++++-
 po/POTFILES.in                 |    1 +
 4 files changed, 52 insertions(+), 2 deletions(-)
---
diff --git a/build/Makefile.am b/build/Makefile.am
index c60a9f6..716be37 100644
--- a/build/Makefile.am
+++ b/build/Makefile.am
@@ -32,7 +32,8 @@ EXTRA_DIST = \
 	TranslatorExtractor.cs \
 	DllMapVerifier.cs \
 	dll-map-makefile-verifier \
-	gconf-schema-rules
+	gconf-schema-rules \
+	addin-xml-string-extract
 
 CLEANFILES = *.exe *.mdb
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/build/addin-xml-string-extract b/build/addin-xml-string-extract
new file mode 100755
index 0000000..a2cf655
--- /dev/null
+++ b/build/addin-xml-string-extract
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use XML::XPath;
+
+my @queries = ('/Addin/@name', '/Addin/@description');
+
+print <<EOF
+// Generated - Do Not Edit!
+
+internal static class AddinXmlStringCatalog
+{
+    private static void Strings ()
+    {
+EOF
+;
+
+foreach (@ARGV) {
+	print "        // $_\n";
+	my $xpath = XML::XPath->new (filename => $_);
+	foreach (@queries) {
+		my $nodes = $xpath->find ($_);
+		if ($nodes->size) {
+			foreach ($nodes->get_nodelist) {
+				print "        Catalog.GetString (\"" . $_->string_value . "\");\n";
+			}
+		}
+	}
+	print "\n";
+}
+
+print <<EOF
+    }
+}
+EOF
+;
+
diff --git a/data/Makefile.am b/data/Makefile.am
index dfe4bec..c306455 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -9,8 +9,18 @@ dbusservice_in_files = \
 dbusservicedir = $(datadir)/dbus-1/services
 dbusservice_DATA = $(dbusservice_in_files:.service.in=.service)
 
+# Generate a fake source file containing strings for
+# translation that are found in our .addin.xml files
+ADDIN_XML_FILES = $(shell find $(top_srcdir) -name \*.addin.xml)
+addin-xml-strings.cs: $(ADDIN_XML_FILES)
+	@echo "  GEN   $@"
+	$(top_srcdir)/build/addin-xml-string-extract $(ADDIN_XML_FILES) > $@
+
+all: addin-xml-strings.cs
+
 EXTRA_DIST = \
-	$(dbusservice_in_files)
+	$(dbusservice_in_files) \
+	addin-xml-strings.cs
 
 DISTCLEANFILES = \
 	$(dbusservice_DATA)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 09db0fb..5a043f2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
 # Please keep this file in alphabetical order; run ./sort-potfiles
 # after adding files here.
 [encoding: UTF-8]
+data/addin-xml-strings.cs
 data/audio-profiles/base.xml.in
 data/audio-profiles/flac.xml.in
 data/audio-profiles/mp3-lame.xml.in



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