gimp-help-2 r2599 - in branches/xml2po-support: . stylesheets tools



Author: ulfehlert
Date: Tue Nov 18 21:00:57 2008
New Revision: 2599
URL: http://svn.gnome.org/viewvc/gimp-help-2?rev=2599&view=rev

Log:
2008-11-18  Ulf-D. Ehlert  <ulfehlert svn gnome org>

	* Makefile.GNU
	* Makefile.am: added XML validation; simplified making of authors.xml

	* stylesheets/authors.xml
	* stylesheets/authors_text.xsl
	* stylesheets/authors_docbook.xsl: simplified making of authors.xml
	(translations in "src/preface/titles.xml" are no longer needed)

	* tools/migrate.sh: format gimp.xml; print runtime info


Modified:
   branches/xml2po-support/ChangeLog
   branches/xml2po-support/Makefile.GNU
   branches/xml2po-support/Makefile.am
   branches/xml2po-support/stylesheets/authors.xml
   branches/xml2po-support/stylesheets/authors_docbook.xsl
   branches/xml2po-support/stylesheets/authors_text.xsl
   branches/xml2po-support/tools/migrate.sh

Modified: branches/xml2po-support/Makefile.GNU
==============================================================================
--- branches/xml2po-support/Makefile.GNU	(original)
+++ branches/xml2po-support/Makefile.GNU	Tue Nov 18 21:00:57 2008
@@ -59,6 +59,7 @@
 htmldir  = html
 pdfdir   = pdf
 odfdir   = odf
+logdir   = log
 
 # Find files and directories
 xml_file_predicates =       \
@@ -174,11 +175,7 @@
 ########################################################################
 
 first: all
-all: validate html index AUTHORS
-
-# ignore
-validate: ;
-
+all: html index AUTHORS
 
 
 ########################################################################
@@ -283,9 +280,34 @@
 # Special case: en
 xml-en: $(xmlpodir)/en ;
 
-# Debugging
-list-xmlfiles-en list-xml-files-en list-xml-en:
-	@echo $(en_XML_FILES)
+
+########################################################################
+####            XML validation                                      ####
+########################################################################
+
+validate: validate-en ;
+validate-%: xmllint-% ;
+xmllint: xmllint-en ;
+
+xmllint-%: $(logdir)/%-xmllint.log ;
+	@echo >&2 "Validating '$*' not implemented."
+
+xmllint-en: $(logdir)/en-xmllint.log ;
+	$(cmd) test -s $< && cat $< || echo "No errors."
+
+$(logdir)/en-xmllint.log: $(logdir) $(XML_FILES)
+	$(cmd) if type $(XMLLINT) >/dev/null 2>&1; then \
+		echo "*** Validating XML for 'en' ... "; \
+		$(XMLLINT) $(XMLLINTFLAGS) --xinclude $(xmlpodir)/en/gimp.xml \
+		| sed -e 's,xmlns:xi="http://www.w3.org/2001/XInclude";,,' \
+		| $(XMLLINT) $(XMLLINTFLAGS) --nonet --valid --noout - 2>$@ \
+		|| true; \
+	else \
+		echo "*** Validating 'en' skipped: 'xmllint' not found."; \
+	fi
+
+$(logdir):
+	$(cmd) mkdir $@ && test -w $@
 
 
 ########################################################################
@@ -443,7 +465,7 @@
 	  $< \
 	  > $@
 	
-$(AUTHORS_DOCBOOK_XML): $(AUTHORS_STYLESHEET_XML) src/preface/titles.xml stylesheets/authors_*.xsl
+$(AUTHORS_DOCBOOK_XML): $(AUTHORS_STYLESHEET_XML) stylesheets/authors_*.xsl
 	$(msg) "**** Making $@ ... "
 	$(cmd) $(XSLTPROC) \
 	  $(XSLTFLAGS) $(XSLTEXTRAFLAGS) \

Modified: branches/xml2po-support/Makefile.am
==============================================================================
--- branches/xml2po-support/Makefile.am	(original)
+++ branches/xml2po-support/Makefile.am	Tue Nov 18 21:00:57 2008
@@ -150,6 +150,7 @@
 htmldir  = html
 pdfdir   = pdf
 odfdir   = odf
+logdir   = log
 
 
 ########################################################################
@@ -191,7 +192,7 @@
 	  $< \
 	  > $@
 	
-$(AUTHORS_DOCBOOK_XML): $(AUTHORS_STYLESHEET_XML) src/preface/titles.xml stylesheets/authors_*.xsl
+$(AUTHORS_DOCBOOK_XML): $(AUTHORS_STYLESHEET_XML) stylesheets/authors_*.xsl
 	@echo "Creating $@"
 	$(cmd) $(XSLTPROC) \
 	  $(XSLTFLAGS) \
@@ -347,6 +348,35 @@
 
 
 ########################################################################
+####            XML validation                                      ####
+########################################################################
+
+validate: validate-en ;
+validate-%: xmllint-% ;
+xmllint: xmllint-en ;
+
+xmllint-%: $(logdir)/%-xmllint.log ;
+	@echo >&2 "Validating '$*' not implemented."
+
+xmllint-en: $(logdir)/en-xmllint.log ;
+	$(cmd) test -s $< && cat $< || echo "No errors."
+
+$(logdir)/en-xmllint.log: $(logdir) $(XML_FILES)
+	$(cmd) if type $(XMLLINT) >/dev/null 2>&1; then \
+		echo "*** Validating XML for 'en' ... "; \
+		$(XMLLINT) $(XMLLINTFLAGS) --xinclude $(xmlpodir)/en/gimp.xml \
+		| sed -e 's,xmlns:xi="http://www.w3.org/2001/XInclude";,,' \
+		| $(XMLLINT) $(XMLLINTFLAGS) --nonet --valid --noout - 2>$@ \
+		|| true; \
+	else \
+		echo "*** Validating 'en' skipped: 'xmllint' not found."; \
+	fi
+
+$(logdir):
+	$(cmd) mkdir $@ && test -w $@
+
+
+########################################################################
 ####            Make HTML files:  XML --> HTML                      ####
 ########################################################################
 

Modified: branches/xml2po-support/stylesheets/authors.xml
==============================================================================
--- branches/xml2po-support/stylesheets/authors.xml	(original)
+++ branches/xml2po-support/stylesheets/authors.xml	Tue Nov 18 21:00:57 2008
@@ -6,6 +6,7 @@
 <!-- It has been copied from gimp and customized. -->
 
 <gimp-authors xmlns="http://purl.org/dc/elements/1.1/";>
+  <title>GIMP User Manual</title>
   <creator role="documenter technican" lang="de en">Axel Wernicke</creator>
   <creator role="documenter artist technican" lang="de en">RÃman Joost</creator>
   <creator role="documenter" lang="de">Ulf-D. Ehlert</creator>

Modified: branches/xml2po-support/stylesheets/authors_docbook.xsl
==============================================================================
--- branches/xml2po-support/stylesheets/authors_docbook.xsl	(original)
+++ branches/xml2po-support/stylesheets/authors_docbook.xsl	Tue Nov 18 21:00:57 2008
@@ -5,23 +5,20 @@
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 xmlns:dc="http://purl.org/dc/elements/1.1/";
-                xmlns:gimp-help="http://www.gimp.org/docs";
-                exclude-result-prefixes="dc gimp-help">
+                exclude-result-prefixes="dc">
 
-  <!-- importing instead of including should avoid 
-       any problems with duplicate definitions -->
+  <!-- import template "lang.split"
+       (importing instead of including should avoid 
+       any problems with duplicate definitions) -->
   <xsl:import href="authors_text.xsl" />
 
-  <xsl:output method="xml" indent="yes"
+  <xsl:output method="xml" encoding="UTF-8" indent="yes"
               doctype-public="-//OASIS//DTD DocBook XML V4.3//EN"
               doctype-system="http://www.docbook.org/xml/4.3/docbookx.dtd"/>
 
   <xsl:param name="roles">creator documenter artist technican</xsl:param>
   <xsl:param name="print.roles.with.lang">creator documenter</xsl:param>
 
-  <!-- read translations of titles and phrases -->
-  <xsl:variable name="i18n"
-    select="document('../src/preface/titles.xml')"/>
 
   <!-- ============================================================= -->
   <xsl:template match="/dc:gimp-authors">
@@ -29,17 +26,19 @@
 <xsl:comment>
     Do not edit this file directly. It was generated automatically
     from "stylesheets/authors.xml".
-    Translations are read from "src/preface/titles.xml".
 </xsl:comment>
 
-    <sect1 id="gimp-team" lang="{$i18n/gimp-help:i18n-phrases/@linguas}">
+    <sect1 id="gimp-team">
       <title>
-        <xsl:for-each
-            select="$i18n/gimp-help:i18n-phrases/i18n-record[ name='authors']/l10n-phrase">
-          <phrase lang="{ lang}">
-            <xsl:value-of select="text()"/>
-          </phrase>
-        </xsl:for-each>
+        <xsl:choose>
+          <xsl:when test="dc:title">
+            <xsl:value-of select="dc:title"/>
+            <xsl:text> Authors and Contributors</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <acronym>GIMP</acronym> User Manual Authors and Contributors
+          </xsl:otherwise>
+        </xsl:choose>
       </title>
     
       <variablelist>
@@ -72,13 +71,28 @@
       <varlistentry>
         <term>
           <xsl:variable name="name" select="concat($role,'s')"/>
-          <!-- extract localized phrases -->
-          <xsl:for-each
-              select="$i18n/gimp-help:i18n-phrases/i18n-record[ name=$name]/l10n-phrase">
-            <phrase lang="{ lang}">
-              <xsl:value-of select="text()"/>
-            </phrase>
-          </xsl:for-each>
+          <xsl:choose>
+            <xsl:when test="$name = 'creators'">
+              <xsl:text>Content Writers</xsl:text>
+            </xsl:when>
+            <xsl:when test="$name = 'documenters'">
+              <xsl:text>Proof Reading</xsl:text>
+            </xsl:when>
+            <xsl:when test="$name = 'artists'">
+              <xsl:text>Graphics, Stylesheets</xsl:text>
+            </xsl:when>
+            <xsl:when test="$name = 'technicans'">
+              <xsl:text>Build System, Technical Contributions</xsl:text>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:message>
+                <xsl:text>ERROR: Unknown role '</xsl:text>
+                <xsl:value-of select="$name"/> 
+                <xsl:text>' in "authors_docbook.xml".</xsl:text>
+              </xsl:message>
+              <xsl:text>FIXME</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
         </term>
         <listitem>
           <simplelist type="inline">

Modified: branches/xml2po-support/stylesheets/authors_text.xsl
==============================================================================
--- branches/xml2po-support/stylesheets/authors_text.xsl	(original)
+++ branches/xml2po-support/stylesheets/authors_text.xsl	Tue Nov 18 21:00:57 2008
@@ -80,53 +80,33 @@
     </xsl:choose>
   </xsl:template>
 
-  <!-- yesss.. this can be way better implemented -->
   <xsl:template name="print.lang">
     <xsl:param name="langid" />
-    <xsl:if test="$langid = 'de'">
-      <xsl:text>German</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'en'">
-      <xsl:text>English</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'it'">
-      <xsl:text>Italian</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'pl'">
-      <xsl:text>Polish</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'fr'">
-      <xsl:text>French</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'es'">
-      <xsl:text>Spanish</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'ko'">
-      <xsl:text>Korean</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'sv'">
-      <xsl:text>Swedish</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'ru'">
-      <xsl:text>Russian</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'cz'">
-      <xsl:text>Czech</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'hr'">
-      <xsl:text>Croatian</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'lt'">
-      <xsl:text>Lithuanian</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'nl'">
-      <xsl:text>Dutch</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'no'">
-      <xsl:text>Norwegian</xsl:text>
-    </xsl:if>
-    <xsl:if test="$langid = 'zh_CN'">
-      <xsl:text>Chinese</xsl:text>
+    <!-- use underscores for spaces within languages,
+         e.g. xx:Pidgin_English -->
+    <xsl:variable name="languages">
+      cz:Czech
+      de:German
+      en:English
+      es:Spanish
+      fr:French
+      hr:Croatian
+      it:Italian
+      ko:Korean
+      lt:Lithuanian
+      nl:Dutch
+      no:Norwegian
+      pl:Polish
+      ru:Russian
+      sv:Swedish
+      zh_CN:Chinese
+    </xsl:variable>
+    <xsl:variable name="tail"
+      select="substring-after($languages,concat($langid,':'))"/>
+    <xsl:if test="$tail != ''">
+      <xsl:value-of select="translate(
+                              normalize-space(substring-before($tail,' ')),
+                              '_', ' ')"/>
     </xsl:if>
   </xsl:template>
 </xsl:stylesheet>

Modified: branches/xml2po-support/tools/migrate.sh
==============================================================================
--- branches/xml2po-support/tools/migrate.sh	(original)
+++ branches/xml2po-support/tools/migrate.sh	Tue Nov 18 21:00:57 2008
@@ -2,6 +2,8 @@
 # this script migrates the content from DocBook XML files to PO/GETTEXT
 # supported XML files ??!?!
 
+start_time=`date '+%T' 2>/dev/null`
+
 # XXX: what about fi, hr?
 : ${LINGUAS:="de es fr it ko nl no pl ru sv"}
 
@@ -82,12 +84,14 @@
     | tools/migrate/convert-glossary.py --lang "$LINGUAS" \
     | xmllint --nonet --format - \
     > $srcdir/glossary/glossary.xml
+    echo
     echo "Splitting $srcdir/glossary/glossary.xml:"
     $SPLIT --lang="$LINGUAS" --file="$srcdir/glossary/glossary.xml" \
            --dest="$xmldir"/'*'/glossary/
 else
     echo >&2 "ERROR: Cannot make $srcdir/glossary/glossary.xml"
 fi
+echo
 
 test "$1" = "split" && exit 0
 
@@ -105,6 +109,20 @@
     fi
 done
 echo
+echo "Reformatting gimp.xml files:"
+for lang in $LINGUAS; do
+    test "$lang" != "en" || continue
+    xmlfile=$xmldir/$lang/gimp.xml
+    xmllint --nonet --format --output ${xmlfile%.xml}.xmllint $xmlfile
+    if test -s ${xmlfile%.xml}.xmllint && \
+       mv -f ${xmlfile%.xml}.xmllint $xmlfile
+    then
+        echo $xmlfile
+    else
+        echo "ERROR $xmlfile"
+    fi
+done
+echo
 
 test "$1" = "xmllint" && exit 0
 
@@ -155,4 +173,8 @@
 echo $(wc -l "empty files") found. && rm -f "empty files"
 echo
 
-
+if [ -n "$start_time" ]; then
+    echo "Started at  $start_time"
+    echo Finished at `date '+%T'`
+    echo
+fi



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