[banshee] Ported the Perl .addin.xml string extractor to C#
- From: Aaron Bockover <abock src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee] Ported the Perl .addin.xml string extractor to C#
- Date: Tue, 15 Dec 2009 23:32:24 +0000 (UTC)
commit 3c1e019426ff4cce0204643fbe0f5fe5f04ad01c
Author: Aaron Bockover <abockover novell com>
Date: Tue Dec 15 18:39:19 2009 -0500
Ported the Perl .addin.xml string extractor to C#
Apparently XML::XPath is not standard in some distribution's
Perl installation, so just to make life a little easier, I
rewrote the string extractor in C#... sigh.
build/AddinXmlStringExtractor.cs | 44 +++++++++++++++++++++++++++++++++++++
build/Makefile.am | 10 ++++++--
build/addin-xml-string-extract | 45 --------------------------------------
data/Makefile.am | 4 +-
4 files changed, 53 insertions(+), 50 deletions(-)
---
diff --git a/build/AddinXmlStringExtractor.cs b/build/AddinXmlStringExtractor.cs
new file mode 100644
index 0000000..ec3c3f0
--- /dev/null
+++ b/build/AddinXmlStringExtractor.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+public static class AddinXmlStringExtract
+{
+ public static void Main (string [] args)
+ {
+ var queries = new [] {
+ "/Addin/@name",
+ "/Addin/@description",
+ "/Addin/@category"
+ };
+
+ Console.WriteLine (@"// Generated - Do Not Edit!
+
+internal static class AddinXmlStringCatalog
+{
+ private static void Strings ()
+ {");
+
+ foreach (var path in args) {
+ Console.WriteLine (" // {0}", path);
+ var xpath = new XPathDocument (path);
+ var nav = xpath.CreateNavigator ();
+ foreach (var query in queries) {
+ var iter = nav.Select (query);
+ while (iter.MoveNext ()) {
+ var value = iter.Current.Value.Trim ();
+ if (String.IsNullOrEmpty (value) ||
+ value[0] == '@' ||
+ (iter.Current.Name == "category" && value.StartsWith ("required:"))) {
+ continue;
+ }
+ Console.WriteLine (@" Catalog.GetString (@""{0}"");",
+ value.Replace (@"""", @""""""));
+ }
+ }
+ Console.WriteLine ();
+ }
+
+ Console.WriteLine (" }\n}");
+ }
+}
diff --git a/build/Makefile.am b/build/Makefile.am
index 716be37..4cd501c 100644
--- a/build/Makefile.am
+++ b/build/Makefile.am
@@ -3,8 +3,9 @@ SUBDIRS = pkg-config m4
GCONF_SCHEMA_EXTRACTOR_ASSEMBLY = gconf-schema-extractor.exe
TRANSLATOR_EXTRACTOR_ASSEMBLY = translator-extractor.exe
DLL_MAP_VERIFIER_ASSEMBLY = dll-map-verifier.exe
+ADDIN_XML_STRING_EXTRACTOR_ASSEMBLY = addin-xml-string-extractor.exe
-ALL_TARGETS = $(TRANSLATOR_EXTRACTOR_ASSEMBLY) $(DLL_MAP_VERIFIER_ASSEMBLY)
+ALL_TARGETS = $(TRANSLATOR_EXTRACTOR_ASSEMBLY) $(DLL_MAP_VERIFIER_ASSEMBLY) $(ADDIN_XML_STRING_EXTRACTOR_ASSEMBLY)
if GCONF_SCHEMAS_INSTALL
bansheedir = $(pkglibdir)
@@ -25,15 +26,18 @@ $(TRANSLATOR_EXTRACTOR_ASSEMBLY): TranslatorExtractor.cs
$(DLL_MAP_VERIFIER_ASSEMBLY): DllMapVerifier.cs
$(MCS) -out:$@ $<
+$(ADDIN_XML_STRING_EXTRACTOR_ASSEMBLY): AddinXmlStringExtractor.cs
+ $(MCS) -r:System.Xml -out:$@ $<
+
EXTRA_DIST = \
icon-theme-installer \
private-icon-theme-installer \
GConfSchemaExtractor.cs \
TranslatorExtractor.cs \
DllMapVerifier.cs \
+ AddinXmlStringExtractor.cs \
dll-map-makefile-verifier \
- gconf-schema-rules \
- addin-xml-string-extract
+ gconf-schema-rules
CLEANFILES = *.exe *.mdb
MAINTAINERCLEANFILES = Makefile.in
diff --git a/data/Makefile.am b/data/Makefile.am
index e1f33ef..7269fab 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -12,9 +12,9 @@ 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) $(top_srcdir)/build/addin-xml-string-extract
+addin-xml-strings.cs: $(ADDIN_XML_FILES) $(top_srcdir)/build/addin-xml-string-extractor.exe
@echo " GEN $@"
- $(top_srcdir)/build/addin-xml-string-extract $(ADDIN_XML_FILES) > $@
+ $(MONO) $(top_srcdir)/build/addin-xml-string-extractor.exe $(ADDIN_XML_FILES) > $@
all: addin-xml-strings.cs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]