Hi,

I want monkeyguide to support better localization. Here is a patch
for stylesheet and makefile to make it possible. To build localized
handbook, for example, use "make LOCALE=ja" .
Here's an example sshot:
http://monkey.workarea.jp/tmp/20050203/monkeyguide-ja-sshot.jpg

If it looks good, I'll commit later.

Love,
Atsushi Eno
Index: mkmstoc-new.xsl
===================================================================
--- mkmstoc-new.xsl     (revision 40055)
+++ mkmstoc-new.xsl     (working copy)
@@ -5,6 +5,8 @@
        
 <xsl:output method="xml" indent="yes" /> 
 
+<xsl:param name="locale" select="'en'" />
+
 <xsl:template match = "/" >
        <html>
                <head>
@@ -19,7 +21,7 @@
                                <li>
                                        <object type="text/sitemap">
                                                <param name="Name" value="The 
Mono Handbook" />
-                                               <param name="Local" 
value="new/en/index.html" />
+                                               <param name="Local" 
value="new/{$locale}/index.html" />
                                        </object>
                                </li>
                                
@@ -35,7 +37,7 @@
        <li>
                <object type="text/sitemap">
                        <param name="Name" value="Appendices" />
-                       <param name="Local" value="new/en/empty.html" />
+                       <param name="Local" value="new/{$locale}/empty.html" />
                </object>
        </li>
        <xsl:if test="count(*)">
@@ -46,15 +48,31 @@
 </xsl:template>
 
 <xsl:template match="part|chapter|doc">
+       <xsl:variable name="localized" select="concat('new/', $locale, '/', 
@href)" />
        <li>
                <object type="text/sitemap">
                        <param name="Name" value="[EMAIL PROTECTED]" />
                        <xsl:choose>
                                <xsl:when test="@href != ''" >
-                                       <param name="Local" 
value="new/en/[EMAIL PROTECTED]" />
+                                       <xsl:choose>
+                                               <xsl:when 
test="document($localized)">
+                                                       <!-- <xsl:message>found 
localized document: <xsl:value-of select="$localized" /></xsl:message> -->
+                                                       <param name="Local" 
value="{$localized}" />
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <param name="Local" 
value="new/en/[EMAIL PROTECTED]" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                </xsl:when>
                                <xsl:otherwise >
-                                       <param name="Local" 
value="new/en/empty.html" />
+                                       <xsl:choose>
+                                               <xsl:when 
test="document('new/{$locale}/empty.html')">
+                                                       <param name="Local" 
value="new/{$locale}/empty.html" />
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <param name="Local" 
value="new/en/empty.html" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                </xsl:otherwise>
                        </xsl:choose>
                </object>
Index: makefile
===================================================================
--- makefile    (revision 40056)
+++ makefile    (working copy)
@@ -8,21 +8,22 @@
 MONO=mono
 SOURCESDIR=`monodoc --get-sourcesdir`
 XSLTPROC=`which xsltproc`
+LOCALE=en
 
 # rules for new / rewritten monkeyguide
 new: monohb-new.tree monohb-new.zip
        mv monohb-new.tree monohb.tree
        mv monohb-new.zip monohb.zip
 
-monohb-new.tree monohb-new.zip: Documentation-new.xml new/en/index.html 
$(shell find new/en -name "*.html" )
+monohb-new.tree monohb-new.zip: Documentation-new.xml new/$(LOCALE)/index.html 
$(shell find new/$(LOCALE) -name "*.html" ) $(shell find new/en -name "*.html" )
        xmllint --noout $?
        cp Documentation-new.xml Documentation.xml # assembler.exe doesn't like 
other names
        $(MONO) $(SOURCESDIR)/../assembler.exe --hb Documentation-new.xml --out 
monohb-new
 
 Documentation-new.xml : mkmstoc-new.xsl toc2.xml
-       $(XSLTPROC) mkmstoc-new.xsl toc2.xml > Documentation-new.xml
+       $(XSLTPROC) --stringparam locale $(LOCALE) mkmstoc-new.xsl toc2.xml > 
Documentation-new.xml
 
-new/en/index.html : mkindex.xsl toc2.xml
+new/$(LOCALE)/index.html : mkindex.xsl toc2.xml
        $(XSLTPROC) mkindex.xsl toc2.xml > $@
 
 clean-new:

Reply via email to