[yelp-xsl] gettext: New translation infrastructure



commit 5df27b50a54302a741f6fc08b76d8d34c13e3c3b
Author: Shaun McCance <shaunm gnome org>
Date:   Wed May 18 12:04:51 2011 -0400

    gettext: New translation infrastructure

 .gitignore                           |    1 +
 Makefile.am                          |    3 +-
 configure.ac                         |   10 +
 gnome-autogen.sh                     |  427 ------------
 po/POTFILES.in                       |    2 +-
 xslt/common/icons.xsl                |    8 +-
 xslt/docbook/html/db2html-inline.xsl |    6 +-
 xslt/gettext/Makefile.am             |   14 +-
 xslt/gettext/domains/Makefile.am     |   31 +
 xslt/gettext/domains/msgs.xsl        |   43 ++
 xslt/gettext/domains/yelp-xsl.pot    |  366 ++++++++++
 xslt/gettext/domains/yelp-xsl.xml.in |  628 +++++++++++++++++
 xslt/gettext/gettext.xsl             |  542 +++------------
 xslt/gettext/l10n.xml.in             | 1235 ----------------------------------
 14 files changed, 1190 insertions(+), 2126 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b3bdcef..84a83b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,4 +84,5 @@ yelp-xsl.pc
 /doc/yelp-xsl/C/mal2xhtml.page
 /doc/yelp-xsl/C/utils.page
 /xslt/theme/test-theme.html
+/xslt/gettext/domains/yelp-xsl.xml
 /test/testdocs/html
diff --git a/Makefile.am b/Makefile.am
index cb28911..ccef253 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
-SUBDIRS = icons js xslt doc po
+SUBDIRS = icons js xslt doc
+DIST_SUBDIRS = $(SUBDIRS) po
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
diff --git a/configure.ac b/configure.ac
index 2575e38..138d88d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,12 @@ else
 fi
 AC_SUBST(YELP_XSL_AWK)
 
+AC_ARG_VAR([ITSTOOL], [Path to the `itstool` command])
+AC_CHECK_PROG([ITSTOOL], [itstool], [itstool])
+if test x"$ITSTOOL" = x; then
+  AC_MSG_ERROR([itstool is required to build the translation XML files])
+fi
+
 # Dependecies
 PKG_CHECK_MODULES(YELP_XSL,
 [
@@ -31,6 +37,9 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE")
 
 IT_PROG_INTLTOOL([0.40.0])
 
+ALL_LINGUAS="`grep -v '^#' "$srcdir/po/LINGUAS" | tr '\n' ' '`"
+AC_SUBST(ALL_LINGUAS)
+
 AC_ARG_ENABLE(doc,
               [AS_HELP_STRING([--enable-doc],[build and install developer documentation [default=no]])],,
               enable_doc=no)
@@ -64,6 +73,7 @@ xslt/mallard/cache/Makefile
 xslt/mallard/common/Makefile
 xslt/mallard/html/Makefile
 xslt/gettext/Makefile
+xslt/gettext/domains/Makefile
 ])
 
 AC_OUTPUT
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d494f51..73450d7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,4 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 [encoding: UTF-8]
-xslt/gettext/l10n.xml.in
+xslt/gettext/domains/yelp-xsl.pot
diff --git a/xslt/common/icons.xsl b/xslt/common/icons.xsl
index 3e39d14..869ae82 100644
--- a/xslt/common/icons.xsl
+++ b/xslt/common/icons.xsl
@@ -135,9 +135,11 @@ language your document is written in.
 -->
 <xsl:param name="icons.quote">
   <xsl:value-of select="$icons.base_url"/>
-  <xsl:call-template name="l10n.gettext">
-    <xsl:with-param name="msgid" select="'yelp-quote-201C.png'"/>
-  </xsl:call-template>
+  <xsl:for-each select="/*">
+    <xsl:call-template name="l10n.gettext">
+      <xsl:with-param name="msgid" select="'yelp-quote-201C.png'"/>
+    </xsl:call-template>
+  </xsl:for-each>
 </xsl:param>
 
 
diff --git a/xslt/docbook/html/db2html-inline.xsl b/xslt/docbook/html/db2html-inline.xsl
index e85da22..7a3f373 100644
--- a/xslt/docbook/html/db2html-inline.xsl
+++ b/xslt/docbook/html/db2html-inline.xsl
@@ -731,12 +731,10 @@ FIXME
 <xsl:template mode="db2html.inline.content.mode" match="menuchoice | db:menuchoice">
   <xsl:variable name="arrow">
     <xsl:variable name="ltr">
-      <xsl:call-template name="l10n.gettext">
-        <xsl:with-param name="msgid" select="'default:LTR'"/>
-      </xsl:call-template>
+      <xsl:call-template name="l10n.direction"/>
     </xsl:variable>
     <xsl:choose>
-      <xsl:when test="$ltr = 'default:RTL'">
+      <xsl:when test="$ltr = 'rtl'">
         <xsl:text>&#x25C2;</xsl:text>
       </xsl:when>
       <xsl:otherwise>
diff --git a/xslt/gettext/Makefile.am b/xslt/gettext/Makefile.am
index 7837ee1..9637ce2 100644
--- a/xslt/gettext/Makefile.am
+++ b/xslt/gettext/Makefile.am
@@ -1,17 +1,9 @@
-# Not using INTLTOOL_XML_RULE because of it causes l10n.xml to be rebuilt
-# in the tarball, which causes docs to be rebuilt, which causes translated
-# docs to be rebuilt, which requires xml2po, which breaks --disable-build-utils
-l10n.xml: l10n.xml.in $(wildcard $(top_srcdir)/po/*.po)
-	LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
-	xmllint --noout $@ || (mv $@ $  broken && false)
+SUBDIRS = domains
 
 xsldir=$(datadir)/yelp-xsl/xslt/gettext
 
 xsl_DATA =			\
 	gettext.xsl		\
-	l10n-numbers.xsl	\
-	l10n.xml
+	l10n-numbers.xsl
 
-EXTRA_DIST=$(xsl_DATA) l10n.xml.in
-
-CLEANFILES = l10n.xml
+EXTRA_DIST = $(xsl_DATA)
diff --git a/xslt/gettext/domains/Makefile.am b/xslt/gettext/domains/Makefile.am
new file mode 100644
index 0000000..79d5474
--- /dev/null
+++ b/xslt/gettext/domains/Makefile.am
@@ -0,0 +1,31 @@
+ALL_LINGUAS = @ALL_LINGUAS@
+
+$(srcdir)/yelp-xsl.pot: yelp-xsl.xml.in
+	itstool -o "$@" yelp-xsl.xml.in
+
+all: $(srcdir)/yelp-xsl.pot
+
+yelp-xsl.xml: yelp-xsl.xml.in
+	@echo "  GEN    $@"; \
+	if [ ! -d .yelp-xsl ]; then mkdir .yelp-xsl; fi; \
+	echo '<files>' > ".yelp-xsl.files"; \
+	echo '<source href="yelp-xsl.xml.in"/>' >> ".yelp-xsl.files"; \
+	for lang in $(ALL_LINGUAS); do \
+	  msgfmt -o ".yelp-xsl/$$lang.mo" "$(top_srcdir)/po/$$lang.po" || exit 1; \
+	  (cd .yelp-xsl && itstool -o "$$lang.xml" -m "$$lang.mo" "../yelp-xsl.xml.in") || exit 1; \
+	  rm ".yelp-xsl/$$lang.mo" || exit 1; \
+	  echo '<file href="'".yelp-xsl/$$lang.xml"'"/>' >> ".yelp-xsl.files"; \
+	done; \
+	echo '</files>' >> ".yelp-xsl.files"; \
+	xsltproc -o "$@" "msgs.xsl" ".yelp-xsl.files" || exit 1; \
+	for lang in $(ALL_LINGUAS); do rm ".yelp-xsl/$$lang.xml"; done; \
+	rmdir .yelp-xsl; \
+	rm .yelp-xsl.files
+
+xsldir=$(datadir)/yelp-xsl/xslt/gettext/domains
+
+xsl_DATA = yelp-xsl.xml
+
+EXTRA_DIST = yelp-xsl.xml yelp-xsl.xml.in
+
+CLEANFILES = yelp-xsl.xml yelp-xsl.pot
diff --git a/xslt/gettext/domains/msgs.xsl b/xslt/gettext/domains/msgs.xsl
new file mode 100644
index 0000000..d0d9a3b
--- /dev/null
+++ b/xslt/gettext/domains/msgs.xsl
@@ -0,0 +1,43 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                xmlns:msg="http://projects.gnome.org/yelp/gettext/";
+                xmlns="http://projects.gnome.org/yelp/gettext/";
+                version="1.0">
+
+<xsl:output method="xml" encoding="UTF-8"/>
+
+<xsl:variable name="source" select="document(/files/source/@href)"/>
+<xsl:variable name="files" select="/files/file"/>
+
+<xsl:key name="id.key" match="msg:msg" use="@id"/>
+
+<xsl:template match="/files">
+  <msg:l10n>
+    <xsl:apply-templates select="$source/msg:l10n/msg:msg"/>
+  </msg:l10n>
+</xsl:template>
+
+<xsl:template match="msg:msg">
+  <xsl:variable name="id" select="@id"/>
+  <msg:msg id="{$id}">
+    <msg:msgstr xml:lang="C">
+      <xsl:for-each select="msg:msgstr/node()">
+        <xsl:copy/>
+      </xsl:for-each>
+    </msg:msgstr>
+    <xsl:for-each select="$files">
+      <xsl:for-each select="document(@href)/*">
+        <xsl:variable name="lang" select="@xml:lang"/>
+        <xsl:for-each select="key('id.key', $id)[1]">
+          <msg:msgstr xml:lang="{$lang}">
+            <xsl:for-each select="msg:msgstr/node()">
+              <xsl:copy/>
+            </xsl:for-each>
+          </msg:msgstr>
+        </xsl:for-each>
+      </xsl:for-each>
+    </xsl:for-each>
+  </msg:msg>
+</xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/xslt/gettext/domains/yelp-xsl.pot b/xslt/gettext/domains/yelp-xsl.pot
new file mode 100644
index 0000000..f2bc296
--- /dev/null
+++ b/xslt/gettext/domains/yelp-xsl.pot
@@ -0,0 +1,366 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2011-05-18 11:35-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL ADDRESS>\n"
+"Language-Team: LANGUAGE <LL li org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Translate to default:RTL if your language should be displayed
+#. right-to-left, otherwise translate to default:LTR.  Do *not*
+#. translate it to "predefinito:LTR", if it isn't default:LTR
+#. or default:RTL it will not work.
+#. 
+#: yelp-xsl.xml.in:28(msg/msgstr)
+msgid "default:LTR"
+msgstr ""
+
+#. This is used a simple list item seperator in places where simple
+#. inline lists have to be constructed dynamically.  Using the default
+#. string of ", ", a list would look like this: A, B, C, D.  Using the
+#. nonsensical string " - ", a list would look like this: A - B - C - D.
+#. 
+#. Make sure to include leading or trailing spaces if you want them.
+#. 
+#: yelp-xsl.xml.in:41(msg/msgstr)
+#, no-wrap
+msgid ""
+", "
+msgstr ""
+
+#. This is used as the final separator in an inline list of three or
+#. more elements.  The string ", " will be used to separate all but
+#. the last pair of elements.  Using these two strings, a list of
+#. names would be formatted as "Tom, Dick, and Harry".
+#. 
+#. Make sure to include leading or trailing spaces if you want them.
+#. 
+#: yelp-xsl.xml.in:54(msg/msgstr)
+#, no-wrap
+msgid ""
+", and "
+msgstr ""
+
+#. This is used as a list item seperator for inline lists of exactly two
+#. elements.  A list of two names would be formatted as "Tom and Dick".
+#. 
+#. Make sure to include leading or trailing spaces if you want them.
+#. 
+#: yelp-xsl.xml.in:65(msg/msgstr)
+#, no-wrap
+msgid ""
+" and "
+msgstr ""
+
+#. http://www.docbook.org/tdg/en/html/qandaentry.html
+#. 
+#. This is used as a label before questions in a question-and-answer
+#. set.  Typically, questions are simply numbered and answers are not
+#. labelled at all.  However, DocBook allows document authors to set
+#. the labelling style for a qandaset.  If the labelling style is set
+#. to 'qanda', this string will be used to label questions.
+#. 
+#: yelp-xsl.xml.in:80(msg/msgstr)
+msgid "Q:"
+msgstr ""
+
+#. http://www.docbook.org/tdg/en/html/qandaentry.html
+#. 
+#. This is used as a label before answers in a question-and-answer
+#. set.  Typically, answers are simply numbered and answers are not
+#. labelled at all.  However, DocBook allows document authors to set
+#. the labelling style for a qandaset.  If the labelling style is set
+#. to 'qanda', this string will be used to label answers.
+#. 
+#: yelp-xsl.xml.in:93(msg/msgstr)
+msgid "A:"
+msgstr ""
+
+#. Default title for a bibliography.
+#: yelp-xsl.xml.in:100(msg/msgstr)
+msgid "Bibliography"
+msgstr ""
+
+#. Revision status of a document or page. Content has been written and
+#. reviewed, and it awaiting a final approval.
+#. 
+#: yelp-xsl.xml.in:110(msg/msgstr)
+msgid "Candidate"
+msgstr ""
+
+#. Default title for a colophon section.
+#: yelp-xsl.xml.in:116(msg/msgstr)
+msgid "Colophon"
+msgstr ""
+
+#. Title of the listing of subsections.
+#: yelp-xsl.xml.in:122(msg/msgstr)
+msgid "Contents"
+msgstr ""
+
+#. Default title for a dedication section.
+#: yelp-xsl.xml.in:127(msg/msgstr)
+msgid "Dedication"
+msgstr ""
+
+#. Revision status of a document or page. Most content has been
+#. written, but revisions are still happening.
+#. 
+#: yelp-xsl.xml.in:135(msg/msgstr)
+msgid "Draft"
+msgstr ""
+
+#. Revision status of a document or page. A senior member of the
+#. documentation team has reviewed and approved.
+#. 
+#: yelp-xsl.xml.in:143(msg/msgstr)
+msgid "Final"
+msgstr ""
+
+#. Automatic heading above a list of related links.
+#: yelp-xsl.xml.in:148(msg/msgstr)
+msgid "Further Reading"
+msgstr ""
+
+#. Default title for a glossary.
+#: yelp-xsl.xml.in:153(msg/msgstr)
+msgid "Glossary"
+msgstr ""
+
+#. Revision status of a document or page. Work has begun, but
+#. not all content has been written.
+#. 
+#: yelp-xsl.xml.in:161(msg/msgstr)
+msgid "Incomplete"
+msgstr ""
+
+#. Default title for an index of terms in a book.
+#: yelp-xsl.xml.in:166(msg/msgstr)
+msgid "Index"
+msgstr ""
+
+#. Automatic heading above a list of guide links.
+#: yelp-xsl.xml.in:171(msg/msgstr)
+msgid "More About"
+msgstr ""
+
+#. Default title for a refnamediv element. This is the common section
+#. title found in most UNIX man pages.
+#. 
+#: yelp-xsl.xml.in:180(msg/msgstr)
+msgid "Name"
+msgstr ""
+
+#. Link text for a link to the next page in a series.
+#: yelp-xsl.xml.in:185(msg/msgstr)
+msgid "Next"
+msgstr ""
+
+#. Revision status of a document or page. Content was once current,
+#. but needs to be updated to reflect software updates.
+#. 
+#: yelp-xsl.xml.in:194(msg/msgstr)
+msgid "Outdated"
+msgstr ""
+
+#. Tooltip on play/pause buttons for audio and video objects.
+#: yelp-xsl.xml.in:199(msg/msgstr)
+msgid "Pause"
+msgstr ""
+
+#. Tooltip on play/pause buttons for audio and video objects.
+#: yelp-xsl.xml.in:204(msg/msgstr)
+msgid "Play"
+msgstr ""
+
+#. Default title for a preface to a book.
+#: yelp-xsl.xml.in:210(msg/msgstr)
+msgid "Preface"
+msgstr ""
+
+#. Link text for a link to the previous page in a series.
+#: yelp-xsl.xml.in:215(msg/msgstr)
+msgid "Previous"
+msgstr ""
+
+#. Revision status of a document or page. Content has been written
+#. and should be reviewed by other team members.
+#. 
+#: yelp-xsl.xml.in:223(msg/msgstr)
+msgid "Ready for review"
+msgstr ""
+
+#. Automatic heading above a list of see-also links.
+#: yelp-xsl.xml.in:228(msg/msgstr)
+msgid "See Also"
+msgstr ""
+
+#. Figures can automatically scale images down to fit the page width.
+#. This is used a tooltip on a link to shrink images back down after
+#. they've been expanded to full size.
+#. 
+#: yelp-xsl.xml.in:237(msg/msgstr)
+msgid "Scale images down"
+msgstr ""
+
+#. Revision status of a document or page. No content has been written yet.
+#. 
+#: yelp-xsl.xml.in:244(msg/msgstr)
+msgid "Stub"
+msgstr ""
+
+#. Default title for a refsynopsisdiv element. This is the common section
+#. title found in most UNIX man pages.
+#. 
+#: yelp-xsl.xml.in:252(msg/msgstr)
+msgid "Synopsis"
+msgstr ""
+
+#. Figures can automatically scale images down to fit the page width.
+#. This is used a tooltip on a link to expand images to full size.
+#. 
+#: yelp-xsl.xml.in:260(msg/msgstr)
+msgid "View images at normal size"
+msgstr ""
+
+#. This is an image of the opening quotation character for your language.
+#. The image is used as a watermark on blockquote elements.  There are a
+#. number of different quote characters used by various languages, so the
+#. image name is translatable.  The name of the icon should be of the form
+#. "yelp-quote-XXXX.png", where XXXX is the Unicode code point of the opening
+#. quote character.  For example, some languages use the double angle quotation
+#. mark.  Translators for these languages should use "yelp-quote-00AB.png".
+#. 
+#. The image, however, is not automatically created.  Do not translate
+#. this to a value if there isn't a corresponding file in yelp-xsl under
+#. the directory icons/hicolor/48x48/status.
+#. 
+#. Languages that use guillemets (angle quotation marks) should use either
+#. 00AB or 00BB, depending on whether the opening quotation is the left
+#. guillemet or the right guillemet.  Languages that use inverted comma
+#. quotation marks should use 201C, 201D, or 201E.  Single quotation marks
+#. don't make very nice watermarks, so if you would normally open a quote
+#. with single quotation marks in your language, use the corresponding
+#. double quotation mark for the watermark image.
+#. 
+#: yelp-xsl.xml.in:287(msg/msgstr)
+msgid "yelp-quote-201C.png"
+msgstr ""
+
+#. ID: biblioentry.tooltip
+#. This is a format message used to format tooltips on cross references
+#. to bibliography entries.
+#. 
+#. Special elements in the message will be replaced with the
+#. appropriate content, as follows:
+#. 
+#. <label/> - The term being defined by the glossary entry
+#. 
+#: yelp-xsl.xml.in:304(msg/msgstr)
+msgid "View the bibliography entry <label/>."
+msgstr ""
+
+#. ID: biblioentry.label.format
+#. This is a format message used to format the labels for entries in
+#. a bibliography.  The content of the label is often an abbreviation
+#. of the authors' names and the year of publication.  In English,
+#. these are generally formatted with [square brackets] surrounding
+#. them.
+#. 
+#. This string is similar to citation.format, but they are used in
+#. different places.  The citation formatter is used when referencing
+#. a bibliography entry in running prose.  This formatter is used for
+#. the actual bibliography entry.  You may use the same formatting for
+#. both, but you don't have to.
+#. 
+#. Special elements in the message will be replaced with the
+#. appropriate content, as follows:
+#. 
+#. <biblioentry.label/> - The text content of the bibliography label
+#. 
+#: yelp-xsl.xml.in:424(msg/msgstr)
+msgid "[<biblioentry.label/>]"
+msgstr ""
+
+#. ID: citation.format
+#. This is a format message used to format inline citations to other
+#. published works.  The content is typically an abbreviation of the
+#. authors' last names.  In English, this abbreviation is usually
+#. written inside [square brackets].
+#. 
+#. Special elements in the message will be replaced with the
+#. appropriate content, as follows:
+#. 
+#. <citation/> - The text content of the citation element, possibly
+#.               as a link to an entry in the bibliography
+#. 
+#: yelp-xsl.xml.in:441(msg/msgstr)
+msgid "[<citation/>]"
+msgstr ""
+
+#. ID: email.tooltip
+#. This is a format message used to format tooltips on mailto: links.
+#. Special elements in the message will be replaced with the appropriate
+#. content, as follows:
+#. 
+#. <string/> - The linked-to email address
+#. 
+#: yelp-xsl.xml.in:453(msg/msgstr)
+msgid "Send email to â??<string/>â??."
+msgstr ""
+
+#. ID: glossentry.tooltip
+#. This is a format message used to format tooltips on cross references
+#. to glossary entries. Special elements in the message will be replaced
+#. with the appropriate content, as follows:
+#. 
+#. <glossterm/> - The term being defined by the glossary entry
+#. 
+#: yelp-xsl.xml.in:465(msg/msgstr)
+msgid "Read the definition for â??<glossterm/>â??."
+msgstr ""
+
+#. ID: glosssee.format
+#. This is a format message used to format glossary cross references.
+#. This format message controls the sentence used to present the cross
+#. reference, not the link itself.  For the formatting of the actual
+#. link, see the message glossentry.xref.
+#. 
+#. One or more glosssee elements are presented as a links to the user
+#. in the glossary, formatted as a single prose sentence.  For example,
+#. if the user is being directed to the entry "foo", the glosssee may
+#. be formatted as "See foo."
+#. 
+#. Special elements in the message will be replaced with the
+#. appropriate content, as follows:
+#. 
+#. <glosssee/> - The actual link or links of the cross reference
+#. 
+#: yelp-xsl.xml.in:486(msg/msgstr)
+msgid "See <glosssee/>."
+msgstr ""
+
+#. ID: glossseealso.format
+#. This is a format message used to format glossary cross references.
+#. This format message controls the sentence used to present the cross
+#. reference, not the link itself.  For the formatting of the actual
+#. link, see the message glossentry.xref.
+#. 
+#. One or more glossseealso elements are presented as a links to the
+#. user in the glossary, formatted as a single prose sentence.  For
+#. example, if the user is being directed to the entries "foo", "bar",
+#. and "baz", the glossseealso may be formatted as "See also foo, bar,
+#. baz."
+#. 
+#. Special elements in the message will be replaced with the
+#. appropriate content, as follows:
+#. 
+#. <glosssee/> - The actual link or links of the cross reference
+#. 
+#: yelp-xsl.xml.in:508(msg/msgstr)
+msgid "See also <glosssee/>."
+msgstr ""
+
diff --git a/xslt/gettext/domains/yelp-xsl.xml.in b/xslt/gettext/domains/yelp-xsl.xml.in
new file mode 100644
index 0000000..7780853
--- /dev/null
+++ b/xslt/gettext/domains/yelp-xsl.xml.in
@@ -0,0 +1,628 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- -*- indent-tabs-mode: nil -*- -->
+
+<l10n xmlns="http://projects.gnome.org/yelp/gettext/";
+      xmlns:msg="http://projects.gnome.org/yelp/gettext/";
+      xmlns:its="http://www.w3.org/2005/11/its";
+      xmlns:itst="http://itstool.org/extensions/";>
+
+<its:rules xmlns:its="http://www.w3.org/2005/11/its";  version="1.0">
+  <its:langRule selector="//*" langPointer="@xml:lang"/>
+
+  <its:translateRule selector="/msg:l10n/msg:msgset" translate="no"/>
+  <its:translateRule selector="/msg:l10n/msg:msg/msg:msgstr" translate="yes"/>
+  <its:withinTextRule selector="/msg:l10n/msg:msg/msg:msgstr//*" withinText="yes"/>
+
+  <itst:preserveSpaceRule selector="/msg:l10n/msg:msg/its:locNote" preserveSpace="yes"/>
+  <its:locNoteRule selector="/msg:l10n/msg:msg/msg:msgstr" locNotePointer="../its:locNote"/>
+</its:rules>
+
+<!-- ======================================================================= -->
+
+<msg id="default:LTR">
+<its:locNote>
+Translate to default:RTL if your language should be displayed
+right-to-left, otherwise translate to default:LTR.  Do *not*
+translate it to "predefinito:LTR", if it isn't default:LTR
+or default:RTL it will not work.
+</its:locNote>
+<msgstr>default:LTR</msgstr>
+</msg>
+
+<!-- FIXME -->
+<msg id="FIXME">
+<its:locNote>
+This is used a simple list item seperator in places where simple
+inline lists have to be constructed dynamically.  Using the default
+string of ", ", a list would look like this: A, B, C, D.  Using the
+nonsensical string " - ", a list would look like this: A - B - C - D.
+
+Make sure to include leading or trailing spaces if you want them.
+</its:locNote>
+<msgstr xml:space="preserve">, </msgstr>
+</msg>
+
+<!-- FIXME -->
+<msg id="FIXME">
+<its:locNote>
+This is used as the final separator in an inline list of three or
+more elements.  The string ", " will be used to separate all but
+the last pair of elements.  Using these two strings, a list of
+names would be formatted as "Tom, Dick, and Harry".
+
+Make sure to include leading or trailing spaces if you want them.
+</its:locNote>
+<msgstr xml:space="preserve">, and </msgstr>
+</msg>
+
+<!-- FIXME -->
+<msg id="FIXME">
+<its:locNote>
+This is used as a list item seperator for inline lists of exactly two
+elements.  A list of two names would be formatted as "Tom and Dick".
+
+Make sure to include leading or trailing spaces if you want them.
+</its:locNote>
+<msgstr xml:space="preserve"> and </msgstr>
+</msg>
+
+<!-- ======================================================================= -->
+
+<msg id="Q:">
+<its:locNote>
+http://www.docbook.org/tdg/en/html/qandaentry.html
+
+This is used as a label before questions in a question-and-answer
+set.  Typically, questions are simply numbered and answers are not
+labelled at all.  However, DocBook allows document authors to set
+the labelling style for a qandaset.  If the labelling style is set
+to 'qanda', this string will be used to label questions.
+</its:locNote>
+<msgstr>Q:</msgstr>
+</msg>
+
+<msg id="A:">
+<its:locNote>
+http://www.docbook.org/tdg/en/html/qandaentry.html
+
+This is used as a label before answers in a question-and-answer
+set.  Typically, answers are simply numbered and answers are not
+labelled at all.  However, DocBook allows document authors to set
+the labelling style for a qandaset.  If the labelling style is set
+to 'qanda', this string will be used to label answers.
+</its:locNote>
+<msgstr>A:</msgstr>
+</msg>
+
+<!-- ======================================================================= -->
+
+<msg id="Bibliography">
+<its:locNote>Default title for a bibliography.</its:locNote>
+<msgstr>Bibliography</msgstr>
+</msg>
+
+<!-- FIXME: update code to call this -->
+<!-- FIXME -->
+<msg id="Candidate">
+<its:locNote>
+Revision status of a document or page. Content has been written and
+reviewed, and it awaiting a final approval.
+</its:locNote>
+<msgstr>Candidate</msgstr>
+</msg>
+
+<!-- FIXME: check code -->
+<msg id="Colophon">
+<its:locNote>Default title for a colophon section.</its:locNote>
+<msgstr>Colophon</msgstr>
+</msg>
+
+<!-- FIXME: check code -->
+<msg id="Contents">
+<its:locNote>Title of the listing of subsections.</its:locNote>
+<msgstr>Contents</msgstr>
+</msg>
+
+<msg id="Dedication">
+<its:locNote>Default title for a dedication section.</its:locNote>
+<msgstr>Dedication</msgstr>
+</msg>
+
+<msg id="Draft">
+<its:locNote>
+Revision status of a document or page. Most content has been
+written, but revisions are still happening.
+</its:locNote>
+<msgstr>Draft</msgstr>
+</msg>
+
+<msg id="Final">
+<its:locNote>
+Revision status of a document or page. A senior member of the
+documentation team has reviewed and approved.
+</its:locNote>
+<msgstr>Final</msgstr>
+</msg>
+
+<msg id="Further Reading">
+<its:locNote>Automatic heading above a list of related links.</its:locNote>
+<msgstr>Further Reading</msgstr>
+</msg>
+
+<msg id="Glossary">
+<its:locNote>Default title for a glossary.</its:locNote>
+<msgstr>Glossary</msgstr>
+</msg>
+
+<msg id="Incomplete">
+<its:locNote>
+Revision status of a document or page. Work has begun, but
+not all content has been written.
+</its:locNote>
+<msgstr>Incomplete</msgstr>
+</msg>
+
+<msg id="Index">
+<its:locNote>Default title for an index of terms in a book.</its:locNote>
+<msgstr>Index</msgstr>
+</msg>
+
+<msg id="More About">
+<its:locNote>Automatic heading above a list of guide links.</its:locNote>
+<msgstr>More About</msgstr>
+</msg>
+
+<!-- FIXME: check code -->
+<msg id="Name">
+<its:locNote>
+Default title for a refnamediv element. This is the common section
+title found in most UNIX man pages.
+</its:locNote>
+<msgstr>Name</msgstr>
+</msg>
+
+<msg id="Next">
+<its:locNote>Link text for a link to the next page in a series.</its:locNote>
+<msgstr>Next</msgstr>
+</msg>
+
+<!-- FIXME: update code to call this -->
+<msg id="Outdated">
+<its:locNote>
+Revision status of a document or page. Content was once current,
+but needs to be updated to reflect software updates.
+</its:locNote>
+<msgstr>Outdated</msgstr>
+</msg>
+
+<msg id="Pause">
+<its:locNote>Tooltip on play/pause buttons for audio and video objects.</its:locNote>
+<msgstr>Pause</msgstr>
+</msg>
+
+<msg id="Play">
+<its:locNote>Tooltip on play/pause buttons for audio and video objects.</its:locNote>
+<msgstr>Play</msgstr>
+</msg>
+
+<!-- FIXME: check code -->
+<msg id="Preface">
+<its:locNote>Default title for a preface to a book.</its:locNote>
+<msgstr>Preface</msgstr>
+</msg>
+
+<msg id="Previous">
+<its:locNote>Link text for a link to the previous page in a series.</its:locNote>
+<msgstr>Previous</msgstr>
+</msg>
+
+<msg id="Ready for review">
+<its:locNote>
+Revision status of a document or page. Content has been written
+and should be reviewed by other team members.
+</its:locNote>
+<msgstr>Ready for review</msgstr>
+</msg>
+
+<msg id="See Also">
+<its:locNote>Automatic heading above a list of see-also links.</its:locNote>
+<msgstr>See Also</msgstr>
+</msg>
+
+<msg id="Scale images down">
+<its:locNote>
+Figures can automatically scale images down to fit the page width.
+This is used a tooltip on a link to shrink images back down after
+they've been expanded to full size.
+</its:locNote>
+<msgstr>Scale images down</msgstr>
+</msg>
+
+<msg id="Stub">
+<its:locNote>
+Revision status of a document or page. No content has been written yet.
+</its:locNote>
+<msgstr>Stub</msgstr>
+</msg>
+
+<msg id="Synopsis">
+<its:locNote>
+Default title for a refsynopsisdiv element. This is the common section
+title found in most UNIX man pages.
+</its:locNote>
+<msgstr>Synopsis</msgstr>
+</msg>
+
+<msg id="View images at normal size">
+<its:locNote>
+Figures can automatically scale images down to fit the page width.
+This is used a tooltip on a link to expand images to full size.
+</its:locNote>
+<msgstr>View images at normal size</msgstr>
+</msg>
+
+<!-- ======================================================================= -->
+
+<msg id="yelp-quote-201C.png">
+<its:locNote>
+This is an image of the opening quotation character for your language.
+The image is used as a watermark on blockquote elements.  There are a
+number of different quote characters used by various languages, so the
+image name is translatable.  The name of the icon should be of the form
+"yelp-quote-XXXX.png", where XXXX is the Unicode code point of the opening
+quote character.  For example, some languages use the double angle quotation
+mark.  Translators for these languages should use "yelp-quote-00AB.png".
+
+The image, however, is not automatically created.  Do not translate
+this to a value if there isn't a corresponding file in yelp-xsl under
+the directory icons/hicolor/48x48/status.
+
+Languages that use guillemets (angle quotation marks) should use either
+00AB or 00BB, depending on whether the opening quotation is the left
+guillemet or the right guillemet.  Languages that use inverted comma
+quotation marks should use 201C, 201D, or 201E.  Single quotation marks
+don't make very nice watermarks, so if you would normally open a quote
+with single quotation marks in your language, use the corresponding
+double quotation mark for the watermark image.
+</its:locNote>
+<msgstr>yelp-quote-201C.png</msgstr>
+</msg>
+
+<!-- ======================================================================= -->
+
+<!-- FIXME: change msg:label, move to db-common -->
+<msg id="biblioentry.tooltip">
+<its:locNote>
+ID: biblioentry.tooltip
+This is a format message used to format tooltips on cross references
+to bibliography entries.
+
+Special elements in the message will be replaced with the
+appropriate content, as follows:
+
+&lt;label/> - The term being defined by the glossary entry
+</its:locNote>
+<msgstr>View the bibliography entry <label/>.</msgstr>
+</msg>
+
+<!-- FIXME: generalize for DocBook -->
+<msgset>
+  <msgstr>comment.cite.name-date.format</msgstr>
+  <!--
+  This is a special format message.  Please read the full translator
+  documentation before translating this message.  The documentation
+  is maintained as part of the stylesheet documentation in DocBook.
+  For your convenience, it has also been converted to an HTML file
+  named STYLESHEETS.xml in the i18n directory.
+
+  comment - Editorial comments
+  cite    - The source of a comment
+  http://projectmallard.org/1.0/mal_block_comment.html
+  http://projectmallard.org/1.0/mal_block_cite.html
+
+  This is a format message used to format the citation of a comment
+  made by an editor of a document. This appears on a new line after
+  the title of the comment, if a title is present, or as the first
+  line if a title is not present.
+
+  This string is used when both the name and the date are supplied.
+  In English, a title together with this format string might produce
+  something like this:
+
+    Some Comment Title
+    from Shaun McCance on 2010-06-03
+
+    Here is the text of the comment.
+
+  If only a name is supplied, and no date, then comment.cite.name.format
+  is used instead of this string.
+
+  Special elements in the message will be replaced with the
+  appropriate content, as follows:
+
+  comment.name - The name of the person making the comment
+  comment.date - The date the comment was made
+
+  These should be written as empty XML elements, e.g. <comment.name/>
+
+  Additionally, format messages can use the i, b, and tt markup tags
+  to mark text as italic, bold, and monospace.
+  -->
+  <_msg>
+    <msgstr>comment.cite.name-date.format</msgstr>
+    <msgstr>from <comment.name/> on <comment.date/></msgstr>
+  </_msg>
+</msgset>
+
+<!-- FIXME: generalize for DocBook -->
+<msgset>
+  <msgstr>comment.cite.name.format</msgstr>
+  <!--
+  This is a special format message.  Please read the full translator
+  documentation before translating this message.  The documentation
+  is maintained as part of the stylesheet documentation in DocBook.
+  For your convenience, it has also been converted to an HTML file
+  named STYLESHEETS.xml in the i18n directory.
+
+  comment - Editorial comments
+  cite    - The source of a comment
+  http://projectmallard.org/1.0/mal_block_comment.html
+  http://projectmallard.org/1.0/mal_block_cite.html
+
+  This is a format message used to format the citation of a comment
+  made by an editor of a document. This appears on a new line after
+  the title of the comment, if a title is present, or as the first
+  line if a title is not present.
+
+  This string is used when only the name of the commenter is supplied.
+  In English, a title together with this format string might produce
+  something like this:
+
+    Some Comment Title
+    from Shaun McCance
+
+    Here is the text of the comment.
+
+  If a date is also supplied, then comment.cite.name-date.format
+  is used instead of this string.
+
+  Special elements in the message will be replaced with the
+  appropriate content, as follows:
+
+  comment.name - The name of the person making the comment
+
+  These should be written as empty XML elements, e.g. <comment.name/>
+
+  Additionally, format messages can use the i, b, and tt markup tags
+  to mark text as italic, bold, and monospace.
+  -->
+  <_msg>
+    <msgstr>comment.cite.name.format</msgstr>
+    <msgstr>from <comment.name/></msgstr>
+  </_msg>
+</msgset>
+
+<msg id="biblioentry.label.format">
+<its:locNote>
+ID: biblioentry.label.format
+This is a format message used to format the labels for entries in
+a bibliography.  The content of the label is often an abbreviation
+of the authors' names and the year of publication.  In English,
+these are generally formatted with [square brackets] surrounding
+them.
+
+This string is similar to citation.format, but they are used in
+different places.  The citation formatter is used when referencing
+a bibliography entry in running prose.  This formatter is used for
+the actual bibliography entry.  You may use the same formatting for
+both, but you don't have to.
+
+Special elements in the message will be replaced with the
+appropriate content, as follows:
+
+&lt;biblioentry.label/> - The text content of the bibliography label
+</its:locNote>
+<msgstr>[<biblioentry.label/>]</msgstr>
+</msg>
+
+<msg id="citation.format">
+<its:locNote>
+ID: citation.format
+This is a format message used to format inline citations to other
+published works.  The content is typically an abbreviation of the
+authors' last names.  In English, this abbreviation is usually
+written inside [square brackets].
+
+Special elements in the message will be replaced with the
+appropriate content, as follows:
+
+&lt;citation/> - The text content of the citation element, possibly
+              as a link to an entry in the bibliography
+</its:locNote>
+<msgstr>[<citation/>]</msgstr>
+</msg>
+
+<msg id="email.tooltip">
+<its:locNote>
+ID: email.tooltip
+This is a format message used to format tooltips on mailto: links.
+Special elements in the message will be replaced with the appropriate
+content, as follows:
+
+&lt;string/> - The linked-to email address
+</its:locNote>
+<msgstr>Send email to â??<string/>â??.</msgstr>
+</msg>
+
+<msg id="glossentry.tooltip">
+<its:locNote>
+ID: glossentry.tooltip
+This is a format message used to format tooltips on cross references
+to glossary entries. Special elements in the message will be replaced
+with the appropriate content, as follows:
+
+&lt;glossterm/> - The term being defined by the glossary entry
+</its:locNote>
+<msgstr>Read the definition for â??<glossterm/>â??.</msgstr>
+</msg>
+
+<msg id="glosssee.format">
+<its:locNote>
+ID: glosssee.format
+This is a format message used to format glossary cross references.
+This format message controls the sentence used to present the cross
+reference, not the link itself.  For the formatting of the actual
+link, see the message glossentry.xref.
+
+One or more glosssee elements are presented as a links to the user
+in the glossary, formatted as a single prose sentence.  For example,
+if the user is being directed to the entry "foo", the glosssee may
+be formatted as "See foo."
+
+Special elements in the message will be replaced with the
+appropriate content, as follows:
+
+&lt;glosssee/> - The actual link or links of the cross reference
+</its:locNote>
+<msgstr>See <glosssee/>.</msgstr>
+</msg>
+
+<msg id="glossseealso.format">
+<its:locNote>
+ID: glossseealso.format
+This is a format message used to format glossary cross references.
+This format message controls the sentence used to present the cross
+reference, not the link itself.  For the formatting of the actual
+link, see the message glossentry.xref.
+
+One or more glossseealso elements are presented as a links to the
+user in the glossary, formatted as a single prose sentence.  For
+example, if the user is being directed to the entries "foo", "bar",
+and "baz", the glossseealso may be formatted as "See also foo, bar,
+baz."
+
+Special elements in the message will be replaced with the
+appropriate content, as follows:
+
+&lt;glosssee/> - The actual link or links of the cross reference
+</its:locNote>
+<msgstr>See also <glosssee/>.</msgstr>
+</msg>
+
+<!-- FIXME: split in two -->
+<msgset>
+  <msgstr>quote.format</msgstr>
+  <!-- 
+  This is a special format message.  Please read the full translator
+  documentation before translating this message.  The documentation
+  is maintained as part of the stylesheet documentation in DocBook.
+  For your convenience, it has also been converted to an HTML file
+  named STYLESHEETS.xml in the i18n directory.
+
+  quote - An inline quotation
+  http://docbook.org/tdg/en/html/quote.html
+
+  This is a format message used to format inline quotations.  This template
+  uses roles to control how the quotation is formatted.  The role indicates
+  whether this is an outer or inner quotation.  Quotations nested inside
+  another quotation are inner quotations.  Many languages have an alternate
+  notation for nested quotations.
+
+  These stylesheets only provide two levels of quotation formatting.  If
+  quote elements are nested deeper, the stylesheets will alternate between
+  the 'outer' and 'inner' roles.  If your language uses different formatting
+  for deeper quotations, please contact the maintainers, and we will try to
+  implement a more flexible formatting mechanism.
+
+  Special elements in the message will be replaced with the
+  appropriate content, as follows:
+
+  node - The text content of the quote element
+
+  These should be written as empty XML elements.  Due to limitations
+  in intltool, I can't write XML content in translator comments.  To
+  insert the node, simply write left angle bracket, node, slash,
+  right angle bracket.
+
+  Additionally, format messages can use the i, b, and tt markup tags
+  to mark text as italic, bold, and monospace.
+  -->
+  <_msg>
+    <msgstr>quote.format</msgstr>
+    <msgstr role='inner'>â??<node/>â??</msgstr>
+    <msgstr>â??<node/>â??</msgstr>
+  </_msg>
+</msgset>    
+
+<!-- FIXME: probably ok, check -->
+<msgset>
+  <msgstr>seeie.format</msgstr>
+  <!--
+  This is a special format message.  Please read the full translator
+  documentation before translating this message.  The documentation
+  is maintained as part of the stylesheet documentation in DocBook.
+  For your convenience, it has also been converted to an HTML file
+  named STYLESHEETS.xml in the i18n directory.
+
+  seeie - A â??Seeâ?? entry in an index, rather than in the text
+  http://www.docbook.org/tdg/en/html/seeie.html
+
+  This is a format message used to format index cross references.
+  This format message controls the sentence used to present the cross
+  reference, not the link itself.
+
+  Special elements in the message will be replaced with the
+  appropriate content, as follows:
+
+  seeie - The actual link or links of the cross reference
+
+  These should be written as empty XML elements.  Due to limitations
+  in intltool, I can't write XML content in translator comments.  To
+  insert the seeie, simply write left angle bracket, seeie, slash,
+  right angle bracket.
+
+  Additionally, format messages can use the i, b, and tt markup tags
+  to mark text as italic, bold, and monospace.
+  -->
+  <_msg>
+    <msgstr>seeie.format</msgstr>
+    <msgstr>See <seeie/>.</msgstr>
+  </_msg>
+</msgset>
+
+<!-- FIXME: probably ok, check -->
+<msgset>
+  <msgstr>seealsoie.format</msgstr>
+  <!--
+  This is a special format message.  Please read the full translator
+  documentation before translating this message.  The documentation
+  is maintained as part of the stylesheet documentation in DocBook.
+  For your convenience, it has also been converted to an HTML file
+  named STYLESHEETS.xml in the i18n directory.
+
+  seealsoie - A â??See alsoâ?? entry in an index, rather than in the text
+  http://www.docbook.org/tdg/en/html/seealsoie.html
+
+  This is a format message used to format index cross references.
+  This format message controls the sentence used to present the cross
+  reference, not the link itself.
+
+  Special elements in the message will be replaced with the
+  appropriate content, as follows:
+
+  seeie - The actual link or links of the cross reference
+
+  These should be written as empty XML elements.  Due to limitations
+  in intltool, I can't write XML content in translator comments.  To
+  insert the seeie, simply write left angle bracket, seeie, slash,
+  right angle bracket.
+
+  Additionally, format messages can use the i, b, and tt markup tags
+  to mark text as italic, bold, and monospace.
+  -->
+  <_msg>
+    <msgstr>seealsoie.format</msgstr>
+    <msgstr>See also <seeie/>.</msgstr>
+  </_msg>
+</msgset>
+
+</l10n>
diff --git a/xslt/gettext/gettext.xsl b/xslt/gettext/gettext.xsl
index e4e48fb..92b4b3d 100644
--- a/xslt/gettext/gettext.xsl
+++ b/xslt/gettext/gettext.xsl
@@ -18,15 +18,24 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 xmlns:msg="http://projects.gnome.org/yelp/gettext/";
+                xmlns:str="http://exslt.org/strings";
+                exclude-result-prefixes="msg str"
                 version="1.0">
 
+<!-- FIXME -->
+<xsl:template name="db.number"/>
+<xsl:template name="db.label"/>
+
+
 <!--!!==========================================================================
 Localized Strings
 -->
 
-<xsl:variable name="l10n" select="document('l10n.xml')"/>
-<xsl:key name="msg" match="msg:msgset/msg:msg"
-         use="concat(../msg:msgid, '__LC__', @xml:lang)"/>
+<xsl:key name="msg" match="msg:msgstr"
+         use="concat(../@id, '__LC__',
+              translate(@xml:lang,
+                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+                        'abcdefghijklmnopqrstuvwxyz'))"/>
 
 
 <!--@@==========================================================================
@@ -44,125 +53,32 @@ The top-level locale of the document
   </xsl:choose>
 </xsl:param>
 
-
-<!--@@==========================================================================
-l10n.language
-The language part of the top-level locale of the document
--->
-<xsl:param name="l10n.language">
-  <xsl:choose>
-    <xsl:when test="contains($l10n.locale, '_')">
-      <xsl:value-of select="substring-before($l10n.locale, '_')"/>
-    </xsl:when>
-    <xsl:when test="contains($l10n.locale, '@')">
-      <xsl:value-of select="substring-before($l10n.locale, '@')"/>
-    </xsl:when>
-    <xsl:when test="contains($l10n.locale, '_')">
-      <xsl:value-of select="substring-before($l10n.locale, '@')"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:value-of select="$l10n.locale"/>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:param>
-
-
-<!--@@==========================================================================
-l10n.region
-The region part of the top-level locale of the document
--->
-<xsl:param name="l10n.region">
-  <xsl:variable name="aft" select="substring-after($l10n.locale, '_')"/>
-  <xsl:choose>
-    <xsl:when test="contains($aft, '@')">
-      <xsl:value-of select="substring-before($aft, '@')"/>
-    </xsl:when>
-    <xsl:when test="contains($aft, '.')">
-      <xsl:value-of select="substring-before($aft, '.')"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:value-of select="$aft"/>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:param>
-
-
-<!--@@==========================================================================
-l10n.variant
-The variant part of the top-level locale of the document
--->
-<xsl:param name="l10n.variant">
-  <xsl:variable name="aft" select="substring-after($l10n.locale, '@')"/>
-  <xsl:choose>
-    <xsl:when test="contains($aft, '.')">
-      <xsl:value-of select="substring-before($aft, '.')"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:value-of select="$aft"/>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:param>
-
-
-<!--@@==========================================================================
-l10n.charset
-The charset part of the top-level locale of the document
--->
-<xsl:param name="l10n.charset">
-  <xsl:if test="contains($l10n.locale, '.')">
-    <xsl:value-of select="substring-after($l10n.locale, '.')"/>
-  </xsl:if>
-</xsl:param>
+<xsl:variable name="l10n.locale.list" select="str:tokenize($l10n.locale, '-_  ')"/>
 
 
 <!--**==========================================================================
 l10n.gettext
 Looks up the translation for a string
-$msgid: The id of the string to look up, often the string in the C locale
-$lang: The locale to use when looking up the translated string
-$lang_language: The language portion of the ${lang}
-$lang_region: The region portion of ${lang}
-$lang_variant: The variant portion of ${lang}
-$lang_charset: The charset portion of ${lang}
-$number: The cardinality for plural-form lookups
-$form: The form name for plural-form lookups
+$domain: The domain to look up the string in.
+$msgid: The id of the string to look up, often the string in the C locale.
+$lang: The locale to use when looking up the translated string.
+$number: The cardinality for plural-form lookups.
+$form: The form name for plural-form lookups.
 
 REMARK: Lots of documentation is needed
 -->
 <xsl:template name="l10n.gettext">
+  <xsl:param name="domain" select="'yelp-xsl'"/>
   <xsl:param name="msgid"/>
-  <xsl:param name="lang" select="ancestor-or-self::*[ lang][1]/@lang |
-                                 ancestor-or-self::*[ xml:lang][1]/@xml:lang"/>
-  <xsl:param name="lang_language">
-    <xsl:call-template name="l10n.language">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_region">
-    <xsl:call-template name="l10n.region">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_variant">
-    <xsl:call-template name="l10n.variant">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_charset">
-    <xsl:call-template name="l10n.charset">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
+  <xsl:param name="lang" select="(ancestor-or-self::*[ lang][1]/@lang |
+                                  ancestor-or-self::*[ xml:lang][1]/@xml:lang)
+                                 [last()]"/>
   <xsl:param name="number"/>
   <xsl:param name="form">
     <xsl:if test="$number">
       <xsl:call-template name="l10n.plural.form">
         <xsl:with-param name="number" select="$number"/>
         <xsl:with-param name="lang" select="$lang"/>
-        <xsl:with-param name="lang_language" select="$lang_language"/>
-        <xsl:with-param name="lang_region"   select="$lang_region"/>
-        <xsl:with-param name="lang_variant"  select="$lang_variant"/>
-        <xsl:with-param name="lang_charset"  select="$lang_charset"/>
       </xsl:call-template>
     </xsl:if>
   </xsl:param>
@@ -171,174 +87,72 @@ REMARK: Lots of documentation is needed
   <xsl:param name="string"/>
   <xsl:param name="format" select="false()"/>
 
-  <xsl:for-each select="$l10n">
+  <xsl:variable name="source" select="."/>
+  <xsl:variable name="normlang" select="translate($lang,
+                                        '_  ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+                                        '---abcdefghijklmnopqrstuvwxyz')"/>
+  <xsl:message>
+    <xsl:value-of select="local-name(/*)"/>
+    <xsl:text> --- </xsl:text>
+    <xsl:value-of select="local-name($source)"/>
+    <xsl:text> --- </xsl:text>
+    <xsl:value-of select="$msgid"/>
+    <xsl:text> --- </xsl:text>
+    <xsl:value-of select="$normlang"/>
+  </xsl:message>
+  <xsl:for-each select="document(concat('domains/', $domain, '.xml'))">
+    <xsl:variable name="msg" select="key('msg', concat($msgid, '__LC__', $normlang))"/>
     <xsl:choose>
-      <!-- fe_fi fo fum -->
-      <xsl:when test="($lang_region and $lang_variant and $lang_charset) and
-                      key('msg', concat($msgid, '__LC__',
-                                        $lang_language, '_', $lang_region,
-                                                        '@', $lang_variant,
-                                                        '.', $lang_charset))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '_', $lang_region,
-                                                     '@', $lang_variant,
-                                                     '.', $lang_charset))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe_fi fo -->
-      <xsl:when test="($lang_region and $lang_variant) and
-                      key('msg', concat($msgid, '__LC__',
-                                        $lang_language, '_', $lang_region,
-                                                        '@', $lang_variant))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '_', $lang_region,
-                                                     '@', $lang_variant))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe fo fum -->
-      <xsl:when test="($lang_variant and $lang_charset) and
-                      key('msg', concat($msgid, '__LC__',
-                                        $lang_language, '@', $lang_variant,
-                                                        '.', $lang_charset))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '@', $lang_variant,
-                                                     '.', $lang_charset))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe fo -->
-      <xsl:when test="($lang_variant) and
-                      key('msg', concat($msgid, '__LC__',
-                                        $lang_language, '@', $lang_variant))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '@', $lang_variant))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe_fi.fum -->
-      <xsl:when test="($lang_region and $lang_charset) and
-                      key('msg', concat($msgid, '__LC__',
-                                        $lang_language, '_', $lang_region,
-                                                        '.', $lang_charset))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '_', $lang_region,
-                                                     '.', $lang_charset))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe_fi -->
-      <xsl:when test="($lang_region) and
-                      key('msg', concat($msgid, '__LC__',
-                                        $lang_language, '_', $lang_region))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '_', $lang_region))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe.fum -->
-      <xsl:when test="($lang_charset) and
-                      key('msg', concat($msgid, '__LC__',
-                                           $lang_language, '.', $lang_charset))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__',
-                                     $lang_language, '.', $lang_charset))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
-      </xsl:when>
-      <!-- fe -->
-      <xsl:when test="key('msg', concat($msgid, '__LC__', $lang_language))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg"
-           select="key('msg', concat($msgid, '__LC__', $lang_language))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
+      <xsl:when test="$msg">
+        <xsl:for-each select="$source">
+          <xsl:call-template name="l10n.gettext.msg">
+            <xsl:with-param name="msg" select="$msg"/>
+            <xsl:with-param name="form" select="$form"/>
+            <xsl:with-param name="node" select="$node"/>
+            <xsl:with-param name="role" select="$role"/>
+            <xsl:with-param name="string" select="$string"/>
+            <xsl:with-param name="format" select="$format"/>
+          </xsl:call-template>
+        </xsl:for-each>
       </xsl:when>
-      <!-- "C" -->
-      <xsl:when test="key('msg', concat($msgid, '__LC__C'))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg" select="key('msg', concat($msgid, '__LC__C'))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
+      <xsl:when test="contains($normlang, '-')">
+        <xsl:variable name="newlang">
+          <xsl:for-each select="str:split($normlang, '-')[position() != last()]">
+            <xsl:if test="position() != 1">
+              <xsl:text>-</xsl:text>
+            </xsl:if>
+            <xsl:value-of select="."/>
+          </xsl:for-each>
+        </xsl:variable>
+        <xsl:for-each select="$source">
+          <xsl:call-template name="l10n.gettext">
+            <xsl:with-param name="domain" select="$domain"/>
+            <xsl:with-param name="msgid" select="$msgid"/>
+            <xsl:with-param name="lang" select="$newlang"/>
+            <xsl:with-param name="number" select="$number"/>
+            <xsl:with-param name="form" select="$form"/>
+            <xsl:with-param name="role" select="$role"/>
+            <xsl:with-param name="string" select="$string"/>
+            <xsl:with-param name="format" select="$format"/>
+          </xsl:call-template>
+        </xsl:for-each>
       </xsl:when>
-      <!-- not() -->
-      <xsl:when test="key('msg', concat($msgid, '__LC__'))">
-        <xsl:call-template name="l10n.gettext.msg">
-          <xsl:with-param
-           name="msg" select="key('msg', concat($msgid, '__LC__'))"/>
-          <xsl:with-param name="form" select="$form"/>
-          <xsl:with-param name="node" select="$node"/>
-          <xsl:with-param name="role" select="$role"/>
-          <xsl:with-param name="string" select="$string"/>
-          <xsl:with-param name="format" select="$format"/>
-        </xsl:call-template>
+      <xsl:when test="$normlang = 'c'">
+        <xsl:value-of select="$msgid"/>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:message>
-          <xsl:text>No translation available for string '</xsl:text>
-          <xsl:value-of select="$msgid"/>
-          <xsl:text>'.</xsl:text>
-        </xsl:message>
-        <xsl:value-of select="$msgid"/>
+        <xsl:for-each select="$source">
+          <xsl:call-template name="l10n.gettext">
+            <xsl:with-param name="domain" select="$domain"/>
+            <xsl:with-param name="msgid" select="$msgid"/>
+            <xsl:with-param name="lang" select="'C'"/>
+            <xsl:with-param name="number" select="$number"/>
+            <xsl:with-param name="form" select="$form"/>
+            <xsl:with-param name="role" select="$role"/>
+            <xsl:with-param name="string" select="$string"/>
+            <xsl:with-param name="format" select="$format"/>
+          </xsl:call-template>
+        </xsl:for-each>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:for-each>
@@ -564,36 +378,14 @@ REMARK: Lots of documentation is needed
 <xsl:template name="l10n.plural.form">
   <xsl:param name="number" select="1"/>
   <xsl:param name="lang" select="$l10n.locale"/>
-  <xsl:param name="lang_language">
-    <xsl:call-template name="l10n.language">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_region">
-    <xsl:call-template name="l10n.region">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_variant">
-    <xsl:call-template name="l10n.variant">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_charset">
-    <xsl:call-template name="l10n.charset">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
+  <xsl:variable name="normlang" select="concat(translate($lang,
+                                        '_  ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+                                        '---abcdefghijklmnopqrstuvwxyz'),
+                                        '-')"/>
 
   <xsl:choose>
-    <!--
-    Keep variants first!
-    When adding new languages, make sure the tests are in a format that
-    can be extracted by the plurals.sh script in the i18n directory.
-    -->
-
     <!-- == pt_BR == -->
-    <xsl:when test="concat($lang_language, '_', $lang_region) = 'pt_BR'">
+    <xsl:when test="starts-with($normlang, 'pt-br-')">
       <xsl:choose>
         <xsl:when test="$number &gt; 1">
           <xsl:text>0</xsl:text>
@@ -605,7 +397,7 @@ REMARK: Lots of documentation is needed
     </xsl:when>
 
     <!-- == ar == -->
-    <xsl:when test="$lang_language = 'ar'">
+    <xsl:when test="starts-with($normlang, 'ar-')">
       <xsl:choose>
         <xsl:when test="$number = 1">
           <xsl:text>0</xsl:text>
@@ -623,9 +415,9 @@ REMARK: Lots of documentation is needed
     </xsl:when>
 
     <!-- == be bs cs ru sr uk == -->
-    <xsl:when test="($lang_language = 'be') or ($lang_language = 'bs') or
-                    ($lang_language = 'cs') or ($lang_language = 'ru') or
-                    ($lang_language = 'sr') or ($lang_language = 'uk') ">
+    <xsl:when test="starts-with($normlang, 'be-') or starts-with($normlang, 'bs-') or
+                    starts-with($normlang, 'cs-') or starts-with($normlang, 'ru-') or
+                    starts-with($normlang, 'sr-') or starts-with($normlang, 'uk-') ">
       <xsl:choose>
         <xsl:when test="($number mod 10 = 1) and ($number mod 100 != 11)">
           <xsl:text>0</xsl:text>
@@ -740,44 +532,18 @@ REMARK: Lots of documentation is needed
 l10n.direction
 Determines the text direction for the language of the document
 $lang: The locale to use to determine the text direction
-$lang_language: The language portion of the ${lang}
-$lang_region: The region portion of ${lang}
-$lang_variant: The variant portion of ${lang}
-$lang_charset: The charset portion of ${lang}
 
 REMARK: Lots of documentation is needed
 -->
 <xsl:template name="l10n.direction">
   <xsl:param name="lang" select="$l10n.locale"/>
-  <xsl:param name="lang_language">
-    <xsl:call-template name="l10n.language">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_region">
-    <xsl:call-template name="l10n.region">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_variant">
-    <xsl:call-template name="l10n.variant">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
-  <xsl:param name="lang_charset">
-    <xsl:call-template name="l10n.charset">
-      <xsl:with-param name="lang" select="$lang"/>
-    </xsl:call-template>
-  </xsl:param>
   <xsl:variable name="direction">
-    <xsl:call-template name="l10n.gettext">
-      <xsl:with-param name="msgid" select="'default:LTR'"/>
-      <xsl:with-param name="lang" select="$lang"/>
-      <xsl:with-param name="lang_language" select="$lang_language"/>
-      <xsl:with-param name="lang_region"   select="$lang_region"/>
-      <xsl:with-param name="lang_variant"  select="$lang_variant"/>
-      <xsl:with-param name="lang_charset"  select="$lang_charset"/>
-    </xsl:call-template>
+    <xsl:for-each select="/*">
+      <xsl:call-template name="l10n.gettext">
+        <xsl:with-param name="msgid" select="'default:LTR'"/>
+        <xsl:with-param name="lang" select="$lang"/>
+      </xsl:call-template>
+    </xsl:for-each>
   </xsl:variable>
   <xsl:choose>
     <xsl:when test="$direction = 'default:RTL'">
@@ -878,118 +644,6 @@ REMARK: Lots of documentation is needed
 </xsl:template>
 
 
-<!--**==========================================================================
-l10n.language
-Extracts the langauge portion of a locale
-$lang: The locale to extract the language from
-
-REMARK: Lots of documentation is needed
--->
-<xsl:template name="l10n.language">
-  <xsl:param name="lang" select="ancestor-or-self::*[ lang][1]/@lang |
-                                 ancestor-or-self::*[ xml:lang][1]/@xml:lang"/>
-  <xsl:choose>
-    <xsl:when test="$lang = $l10n.locale">
-      <xsl:value-of select="$l10n.language"/>
-    </xsl:when>
-    <xsl:when test="contains($lang, '_')">
-      <xsl:value-of select="substring-before($lang, '_')"/>
-    </xsl:when>
-    <xsl:when test="contains($lang, '@')">
-      <xsl:value-of select="substring-before($lang, '@')"/>
-    </xsl:when>
-    <xsl:when test="contains($lang, '_')">
-      <xsl:value-of select="substring-before($lang, '@')"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:value-of select="$lang"/>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-
-<!--**==========================================================================
-l10n.region
-Extracts the region portion of a locale
-$lang: The locale to extract the region from
-
-REMARK: Lots of documentation is needed
--->
-<xsl:template name="l10n.region">
-  <xsl:param name="lang" select="ancestor-or-self::*[ lang][1]/@lang |
-                                 ancestor-or-self::*[ xml:lang][1]/@xml:lang"/>
-  <xsl:choose>
-    <xsl:when test="$lang = $l10n.locale">
-      <xsl:value-of select="$l10n.region"/>
-    </xsl:when>
-    <xsl:when test="contains($lang, '_')">
-      <xsl:variable name="aft" select="substring-after($lang, '_')"/>
-      <xsl:choose>
-        <xsl:when test="contains($aft, '@')">
-          <xsl:value-of select="substring-before($aft, '@')"/>
-        </xsl:when>
-        <xsl:when test="contains($aft, '.')">
-          <xsl:value-of select="substring-before($aft, '.')"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="$aft"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:when>
-  </xsl:choose>
-</xsl:template>
-
-
-<!--**==========================================================================
-l10n.variant
-Extracts the variant portion of a locale
-$lang: The locale to extract the variant from
-
-REMARK: Lots of documentation is needed
--->
-<xsl:template name="l10n.variant">
-  <xsl:param name="lang" select="ancestor-or-self::*[ lang][1]/@lang |
-                                 ancestor-or-self::*[ xml:lang][1]/@xml:lang"/>
-  <xsl:choose>
-    <xsl:when test="$lang = $l10n.locale">
-      <xsl:value-of select="$l10n.variant"/>
-    </xsl:when>
-    <xsl:when test="contains($lang, '@')">
-      <xsl:variable name="aft" select="substring-after($lang, '@')"/>
-      <xsl:choose>
-        <xsl:when test="contains($aft, '.')">
-          <xsl:value-of select="substring-before($aft, '.')"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="$aft"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:when>
-  </xsl:choose>
-</xsl:template>
-
-
-<!--**==========================================================================
-l10n.charset
-Extracts the charset portion of a locale
-$lang: The locale to extract the charset from
-
-REMARK: Lots of documentation is needed
--->
-<xsl:template name="l10n.charset">
-  <xsl:param name="lang" select="ancestor-or-self::*[ lang][1]/@lang |
-                                 ancestor-or-self::*[ xml:lang][1]/@xml:lang"/>
-  <xsl:choose>
-    <xsl:when test="$lang = $l10n.locale">
-      <xsl:value-of select="$l10n.charset"/>
-    </xsl:when>
-    <xsl:when test="contains($lang, '.')">
-      <xsl:value-of select="substring-after($lang, '.')"/>
-    </xsl:when>
-  </xsl:choose>
-</xsl:template>
-
-
 <!--%%==========================================================================
 l10n.format.mode
 FIXME



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