[projectaon] Localized data in the XSLT files

  • From: "Thomas Wolmer" <angantyr@xxxxxxxxx>
  • To: projectaon@xxxxxxxxxxxxx
  • Date: Sun, 2 Apr 2006 22:19:26 +0200

One thing that is not very pretty in our book generation process is
that while most language specific information natuarally exists in the
XML files, some of it is located in the XSLT files. That is both
section titles like "Table of Contents", "Section" and elements of
other generated text, like the publication date which has got the
month spelled out in letters.

In the XSLT code, it basically looks like "if Spanish then ... else
...". Add another language, and we would get "if Spanish then ... else
if Swedish then ... else ...", and so on. In 30 different places. It
will get tedious.

A few of these should be very easy to eliminate; the section titles
"Title Page" and "Table of Contents" could just as well be coded in
the XML files (in fact "Title Page" is, but it is never read?!).

Others are not as easy, like the publication dates, but we could
define such strings in a dictionary which could be a separate XSLT
file, or an element in the XML files (handled as an entity inclusion
so it can be shared between all books of a particular language), from
which the XSL could fetch the strings.

Would we do it like that, the next localization problem we might run
into is where it's not just a word that varies between languages, it's
the order of localized and non-localized data. Take the publication
date:

English: 08 October 2005
Spanish: 08 de octubre de 2005
Swedish: Den 08 oktober 2005

(Actually, there's no need for the "Den" part in Swedish, but let's
pretend there was.)

A standard problem with many standard solutions, like Java's
MessageFormat.format(). How does a good XSLT solution look?

--
Thomas

Other related posts: