better internationalization in docbook-style-xsl

Muayyad AlSadi alsadi at gmail.com
Thu Nov 27 22:41:51 UTC 2008


hi,
I made some patches into docbook-style-xsl-1.74.0-3.fc10.noarch
to make it better for international environment

before you ask me why in devel ML why not doc-ML why not upstream ?
I say because I want to make it better
so that when we upstream it we won't find any issue


for example the file html/docbook.xsl have a header like this
<xsl:output method="html"
            encoding="ISO-8859-1"
            indent="no"/>

while the xhtml/docbook.xsl uses utf-8

changing the first one to be just like the second ie. utf-8 encoding
won't drop any feature but it will produce better files
(if a non-ASCII non-Latin-1 is used with ISO-8859-1 encoding it will
be encoded like this &xxxx; for each char)

second thing,
left and right are not what we want, we want here and there
(in right to left languages left and right are mirrored)
in the ODF standard they call it start and end (start is the same
direction as the current script ie. left for English and right for
Arabic)

I patched the xsl with a script (to make sure they are all fixed
because a diff patch will be broken if the upstream make any change)

for i in html xhtml
do
perl -i -wpe 's/align="left"/align="{\$directions.align.start}"/g' ${i}/*
perl -i -wpe 's/align="right"/align="{\$directions.align.end}"/g' ${i}/*
done

this way all the align="left" will be substituted with the value of
the param directions.align.start ..etc.

we need to declare this param somewhere depending on the locale
so I edited html/param.xml to have something like

<xsl:param name="directions.align.start">
<xsl:choose>
<xsl:when test="$direction='rtl'">right</xsl:when>
<xsl:otherwise>left</xsl:otherwise>
</xsl:choose>
</xsl:param>

<xsl:param name="directions.align.end">
<xsl:choose>
<xsl:when test="$direction='rtl'">left</xsl:when>
<xsl:otherwise>right</xsl:otherwise>
</xsl:choose>
</xsl:param>

which mean if I cant to make a RTL right-to-left document a set a
param called direction to the value rtl
other wise left to right direction will be assumed

I need a better automated way for doing this
I want the direction to be guessed from the language of the document
if it's in the list of right-to-left languages (Arabic, Parisian,
Urdu, Hebrew, ..etc.)
ie. when there
<article id="my_article" lang="ar_JO"> or <book id="my_book" lang="ar_JO">
direction param should be set to rtl

how can I do this last step instead of passing --stringparam direction
rtl to xsltproc




More information about the devel mailing list