Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / common2 / i18n.xsl @ 187

History | View | Annotate | Download (6.6 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet 
3
    xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
4
    xmlns:fo="http://www.w3.org/1999/XSL/Format" 
5
    xmlns:html="http://www.w3.org/1999/xhtml" 
6
    xmlns:i="http://www.iso.org/ns/1.0"
7
    xmlns:rng="http://relaxng.org/ns/structure/1.0"
8
    xmlns:s="http://www.ascc.net/xml/schematron" 
9
    xmlns:sch="http://purl.oclc.org/dsdl/schematron" 
10
    xmlns:tei="http://www.tei-c.org/ns/1.0"
11
    xmlns:teix="http://www.tei-c.org/ns/Examples" 
12
    xmlns:xi="http://www.w3.org/2001/XInclude"
13
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
14
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15
    exclude-result-prefixes="a fo html i rng s sch tei teix xi xs xsl" 
16
    version="2.0">
17
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
18
      <desc>
19
         <p> TEI stylesheet definitions common for all of HTML, FO and LaTeX
20
      outputs </p>
21
         <p>This software is dual-licensed:
22

    
23
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
24
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
25

    
26
2. http://www.opensource.org/licenses/BSD-2-Clause
27
		
28
All rights reserved.
29

    
30
Redistribution and use in source and binary forms, with or without
31
modification, are permitted provided that the following conditions are
32
met:
33

    
34
* Redistributions of source code must retain the above copyright
35
notice, this list of conditions and the following disclaimer.
36

    
37
* Redistributions in binary form must reproduce the above copyright
38
notice, this list of conditions and the following disclaimer in the
39
documentation and/or other materials provided with the distribution.
40

    
41
This software is provided by the copyright holders and contributors
42
"as is" and any express or implied warranties, including, but not
43
limited to, the implied warranties of merchantability and fitness for
44
a particular purpose are disclaimed. In no event shall the copyright
45
holder or contributors be liable for any direct, indirect, incidental,
46
special, exemplary, or consequential damages (including, but not
47
limited to, procurement of substitute goods or services; loss of use,
48
data, or profits; or business interruption) however caused and on any
49
theory of liability, whether in contract, strict liability, or tort
50
(including negligence or otherwise) arising in any way out of the use
51
of this software, even if advised of the possibility of such damage.
52
</p>
53
         <p>Author: See AUTHORS</p>
54
         <p>Id: $Id: i18n.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
55
         <p>Copyright: 2011, TEI Consortium</p>
56
      </desc>
57
   </doc>
58
  <xsl:key match="entry" name="KEYS" use="key"/>
59
  <xsl:param name="documentationLanguage">en</xsl:param>
60

    
61
  <xsl:variable name="i18n"
62
		select="document('../i18n.xml',document(''))"/>
63

    
64
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
65
      <desc>[common] give language-specific version of a word or phrase<param name="word">the word(s) to translate</param>
66
      </desc>
67
   </doc>
68
  <xsl:template name="i18n">
69
      <xsl:param name="word"/>
70
      <xsl:variable name="Word">
71
         <xsl:value-of select="normalize-space($word)"/>
72
      </xsl:variable>
73
      <xsl:variable name="local">
74
         <xsl:call-template name="myi18n">
75
	           <xsl:with-param name="word">
76
	              <xsl:value-of select="$word"/>
77
	           </xsl:with-param>
78
         </xsl:call-template>
79
      </xsl:variable>
80
      <xsl:choose>
81
         <xsl:when test="string-length($local)&gt;0">
82
            <xsl:value-of select="$local"/>
83
         </xsl:when>
84
         <xsl:otherwise>
85
            <xsl:for-each select="$i18n">
86
	      <xsl:choose>
87
		<xsl:when test="key('KEYS',$Word)/text[@xml:lang=$documentationLanguage]">
88
		  <xsl:value-of select="key('KEYS',$Word)/text[@xml:lang=$documentationLanguage]"/>
89
		</xsl:when>
90
		<xsl:when test="key('KEYS',$Word)/text[@lang3=$documentationLanguage]">
91
		  <xsl:value-of select="key('KEYS',$Word)/text[lang3=$documentationLanguage]"/>
92
		</xsl:when>
93
		<xsl:otherwise>
94
		  <!--
95
		      <xsl:if test="$verbose='true'">
96
		      <xsl:message>NO TRANSLATION for <xsl:value-of 
97
		      select="$word"/> in <xsl:value-of select="$documentationLanguage"/></xsl:message>
98
		      </xsl:if>
99
		  -->
100
		  <xsl:value-of select="key('KEYS',$Word)/text[@xml:lang='en']"/>
101
		</xsl:otherwise>
102
	      </xsl:choose>
103
            </xsl:for-each>
104
         </xsl:otherwise>
105
      </xsl:choose>
106
  </xsl:template>
107

    
108
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
109
      <desc>[localisation] dummy template for overriding in a local system<param name="word">the word(s) to translate</param>
110
      </desc>
111
   </doc>
112
  <xsl:template name="myi18n">
113
	     <xsl:param name="word"/>
114
  </xsl:template>
115

    
116
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation" type="string">
117
      <desc> The language to use when
118
    generating text (use ISO 2-letter codes)</desc>
119
   </doc>
120
  <xsl:param name="lang">en</xsl:param>
121
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation">
122
      <desc>[common] Prefix text before an auto-generated table of contents </desc>
123
   </doc>
124
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation" type="string">
125
      <desc> The language the text is in
126
    (use ISO 2-letter codes)</desc>
127
   </doc>
128
  <xsl:param name="doclang">en</xsl:param>
129
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation">
130
      <desc>[common] Prefix text before an auto-generated table of contents </desc>
131
   </doc>
132
  <xsl:template name="contentsHeading">
133
      <xsl:call-template name="i18n">
134
         <xsl:with-param name="word">contentsHeading</xsl:with-param>
135
      </xsl:call-template>
136
  </xsl:template>
137
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation">
138
      <desc>[common] Title for "Contents"; by default uses language-specific
139
      lookup table.</desc>
140
   </doc>
141
  <xsl:template name="contentsWord">
142
      <xsl:call-template name="i18n">
143
         <xsl:with-param name="word">contentsWord</xsl:with-param>
144
      </xsl:call-template>
145
  </xsl:template>
146
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation">
147
      <desc>[common] Title for "Feedback"</desc>
148
   </doc>
149
  <xsl:template name="feedbackWords">
150
      <xsl:call-template name="i18n">
151
         <xsl:with-param name="word">feedbackWords</xsl:with-param>
152
      </xsl:call-template>
153
  </xsl:template>
154
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" class="localisation">
155
      <desc>[common] Title for "Search"; by default uses language-specific
156
      lookup table. </desc>
157
   </doc>
158
  <xsl:template name="searchWords">
159
      <xsl:call-template name="i18n">
160
         <xsl:with-param name="word">searchWords</xsl:with-param>
161
      </xsl:call-template>
162
  </xsl:template>
163
</xsl:stylesheet>