~ubuntu-branches/ubuntu/quantal/yelp-xsl/quantal

« back to all changes in this revision

Viewing changes to xslt/gettext/gettext.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Michael Terry
  • Date: 2011-07-09 10:02:21 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110709100221-5ys7oh9pzgyaaoo4
Tags: 3.1.2-0ubuntu1
* New upstream release.
* debian/control.in:
  - Build-Depend on itstool
  - Point at Ubuntu's branch
* debian/watch:
  - Fix URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
20
                xmlns:msg="http://projects.gnome.org/yelp/gettext/"
 
21
                xmlns:str="http://exslt.org/strings"
 
22
                exclude-result-prefixes="msg str"
21
23
                version="1.0">
22
24
 
 
25
<!-- FIXME -->
 
26
<xsl:template name="db.number"/>
 
27
<xsl:template name="db.label"/>
 
28
 
 
29
 
23
30
<!--!!==========================================================================
24
31
Localized Strings
25
32
-->
26
33
 
27
 
<xsl:variable name="l10n" select="document('l10n.xml')"/>
28
 
<xsl:key name="msg" match="msg:msgset/msg:msg"
29
 
         use="concat(../msg:msgid, '__LC__', @xml:lang)"/>
 
34
<xsl:key name="msg" match="msg:msgstr"
 
35
         use="concat(../@id, '__LC__',
 
36
              translate(@xml:lang,
 
37
                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
 
38
                        'abcdefghijklmnopqrstuvwxyz'))"/>
30
39
 
31
40
 
32
41
<!--@@==========================================================================
44
53
  </xsl:choose>
45
54
</xsl:param>
46
55
 
47
 
 
48
 
<!--@@==========================================================================
49
 
l10n.language
50
 
The language part of the top-level locale of the document
51
 
-->
52
 
<xsl:param name="l10n.language">
53
 
  <xsl:choose>
54
 
    <xsl:when test="contains($l10n.locale, '_')">
55
 
      <xsl:value-of select="substring-before($l10n.locale, '_')"/>
56
 
    </xsl:when>
57
 
    <xsl:when test="contains($l10n.locale, '@')">
58
 
      <xsl:value-of select="substring-before($l10n.locale, '@')"/>
59
 
    </xsl:when>
60
 
    <xsl:when test="contains($l10n.locale, '_')">
61
 
      <xsl:value-of select="substring-before($l10n.locale, '@')"/>
62
 
    </xsl:when>
63
 
    <xsl:otherwise>
64
 
      <xsl:value-of select="$l10n.locale"/>
65
 
    </xsl:otherwise>
66
 
  </xsl:choose>
67
 
</xsl:param>
68
 
 
69
 
 
70
 
<!--@@==========================================================================
71
 
l10n.region
72
 
The region part of the top-level locale of the document
73
 
-->
74
 
<xsl:param name="l10n.region">
75
 
  <xsl:variable name="aft" select="substring-after($l10n.locale, '_')"/>
76
 
  <xsl:choose>
77
 
    <xsl:when test="contains($aft, '@')">
78
 
      <xsl:value-of select="substring-before($aft, '@')"/>
79
 
    </xsl:when>
80
 
    <xsl:when test="contains($aft, '.')">
81
 
      <xsl:value-of select="substring-before($aft, '.')"/>
82
 
    </xsl:when>
83
 
    <xsl:otherwise>
84
 
      <xsl:value-of select="$aft"/>
85
 
    </xsl:otherwise>
86
 
  </xsl:choose>
87
 
</xsl:param>
88
 
 
89
 
 
90
 
<!--@@==========================================================================
91
 
l10n.variant
92
 
The variant part of the top-level locale of the document
93
 
-->
94
 
<xsl:param name="l10n.variant">
95
 
  <xsl:variable name="aft" select="substring-after($l10n.locale, '@')"/>
96
 
  <xsl:choose>
97
 
    <xsl:when test="contains($aft, '.')">
98
 
      <xsl:value-of select="substring-before($aft, '.')"/>
99
 
    </xsl:when>
100
 
    <xsl:otherwise>
101
 
      <xsl:value-of select="$aft"/>
102
 
    </xsl:otherwise>
103
 
  </xsl:choose>
104
 
</xsl:param>
105
 
 
106
 
 
107
 
<!--@@==========================================================================
108
 
l10n.charset
109
 
The charset part of the top-level locale of the document
110
 
-->
111
 
<xsl:param name="l10n.charset">
112
 
  <xsl:if test="contains($l10n.locale, '.')">
113
 
    <xsl:value-of select="substring-after($l10n.locale, '.')"/>
114
 
  </xsl:if>
115
 
</xsl:param>
 
56
<xsl:variable name="l10n.locale.list" select="str:tokenize($l10n.locale, '-_@.')"/>
116
57
 
117
58
 
118
59
<!--**==========================================================================
119
60
l10n.gettext
120
61
Looks up the translation for a string
121
 
$msgid: The id of the string to look up, often the string in the C locale
122
 
$lang: The locale to use when looking up the translated string
123
 
$lang_language: The language portion of the ${lang}
124
 
$lang_region: The region portion of ${lang}
125
 
$lang_variant: The variant portion of ${lang}
126
 
$lang_charset: The charset portion of ${lang}
127
 
$number: The cardinality for plural-form lookups
128
 
$form: The form name for plural-form lookups
 
62
$domain: The domain to look up the string in.
 
63
$msgid: The id of the string to look up, often the string in the C locale.
 
64
$lang: The locale to use when looking up the translated string.
 
65
$number: The cardinality for plural-form lookups.
 
66
$form: The form name for plural-form lookups.
129
67
 
130
68
REMARK: Lots of documentation is needed
131
69
-->
132
70
<xsl:template name="l10n.gettext">
 
71
  <xsl:param name="domain" select="'yelp-xsl'"/>
133
72
  <xsl:param name="msgid"/>
134
 
  <xsl:param name="lang" select="ancestor-or-self::*[@lang][1]/@lang |
135
 
                                 ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
136
 
  <xsl:param name="lang_language">
137
 
    <xsl:call-template name="l10n.language">
138
 
      <xsl:with-param name="lang" select="$lang"/>
139
 
    </xsl:call-template>
140
 
  </xsl:param>
141
 
  <xsl:param name="lang_region">
142
 
    <xsl:call-template name="l10n.region">
143
 
      <xsl:with-param name="lang" select="$lang"/>
144
 
    </xsl:call-template>
145
 
  </xsl:param>
146
 
  <xsl:param name="lang_variant">
147
 
    <xsl:call-template name="l10n.variant">
148
 
      <xsl:with-param name="lang" select="$lang"/>
149
 
    </xsl:call-template>
150
 
  </xsl:param>
151
 
  <xsl:param name="lang_charset">
152
 
    <xsl:call-template name="l10n.charset">
153
 
      <xsl:with-param name="lang" select="$lang"/>
154
 
    </xsl:call-template>
155
 
  </xsl:param>
 
73
  <xsl:param name="lang" select="(ancestor-or-self::*[@lang][1]/@lang |
 
74
                                  ancestor-or-self::*[@xml:lang][1]/@xml:lang)
 
75
                                 [last()]"/>
156
76
  <xsl:param name="number"/>
157
77
  <xsl:param name="form">
158
78
    <xsl:if test="$number">
159
79
      <xsl:call-template name="l10n.plural.form">
160
80
        <xsl:with-param name="number" select="$number"/>
161
81
        <xsl:with-param name="lang" select="$lang"/>
162
 
        <xsl:with-param name="lang_language" select="$lang_language"/>
163
 
        <xsl:with-param name="lang_region"   select="$lang_region"/>
164
 
        <xsl:with-param name="lang_variant"  select="$lang_variant"/>
165
 
        <xsl:with-param name="lang_charset"  select="$lang_charset"/>
166
82
      </xsl:call-template>
167
83
    </xsl:if>
168
84
  </xsl:param>
171
87
  <xsl:param name="string"/>
172
88
  <xsl:param name="format" select="false()"/>
173
89
 
174
 
  <xsl:for-each select="$l10n">
 
90
  <xsl:variable name="source" select="."/>
 
91
  <xsl:variable name="normlang" select="translate($lang,
 
92
                                        '_@.ABCDEFGHIJKLMNOPQRSTUVWXYZ',
 
93
                                        '---abcdefghijklmnopqrstuvwxyz')"/>
 
94
  <xsl:for-each select="document(concat('domains/', $domain, '.xml'))">
 
95
    <xsl:variable name="msg" select="key('msg', concat($msgid, '__LC__', $normlang))"/>
175
96
    <xsl:choose>
176
 
      <!-- fe_fi@fo.fum -->
177
 
      <xsl:when test="($lang_region and $lang_variant and $lang_charset) and
178
 
                      key('msg', concat($msgid, '__LC__',
179
 
                                        $lang_language, '_', $lang_region,
180
 
                                                        '@', $lang_variant,
181
 
                                                        '.', $lang_charset))">
182
 
        <xsl:call-template name="l10n.gettext.msg">
183
 
          <xsl:with-param
184
 
           name="msg"
185
 
           select="key('msg', concat($msgid, '__LC__',
186
 
                                     $lang_language, '_', $lang_region,
187
 
                                                     '@', $lang_variant,
188
 
                                                     '.', $lang_charset))"/>
189
 
          <xsl:with-param name="form" select="$form"/>
190
 
          <xsl:with-param name="node" select="$node"/>
191
 
          <xsl:with-param name="role" select="$role"/>
192
 
          <xsl:with-param name="string" select="$string"/>
193
 
          <xsl:with-param name="format" select="$format"/>
194
 
        </xsl:call-template>
195
 
      </xsl:when>
196
 
      <!-- fe_fi@fo -->
197
 
      <xsl:when test="($lang_region and $lang_variant) and
198
 
                      key('msg', concat($msgid, '__LC__',
199
 
                                        $lang_language, '_', $lang_region,
200
 
                                                        '@', $lang_variant))">
201
 
        <xsl:call-template name="l10n.gettext.msg">
202
 
          <xsl:with-param
203
 
           name="msg"
204
 
           select="key('msg', concat($msgid, '__LC__',
205
 
                                     $lang_language, '_', $lang_region,
206
 
                                                     '@', $lang_variant))"/>
207
 
          <xsl:with-param name="form" select="$form"/>
208
 
          <xsl:with-param name="node" select="$node"/>
209
 
          <xsl:with-param name="role" select="$role"/>
210
 
          <xsl:with-param name="string" select="$string"/>
211
 
          <xsl:with-param name="format" select="$format"/>
212
 
        </xsl:call-template>
213
 
      </xsl:when>
214
 
      <!-- fe@fo.fum -->
215
 
      <xsl:when test="($lang_variant and $lang_charset) and
216
 
                      key('msg', concat($msgid, '__LC__',
217
 
                                        $lang_language, '@', $lang_variant,
218
 
                                                        '.', $lang_charset))">
219
 
        <xsl:call-template name="l10n.gettext.msg">
220
 
          <xsl:with-param
221
 
           name="msg"
222
 
           select="key('msg', concat($msgid, '__LC__',
223
 
                                     $lang_language, '@', $lang_variant,
224
 
                                                     '.', $lang_charset))"/>
225
 
          <xsl:with-param name="form" select="$form"/>
226
 
          <xsl:with-param name="node" select="$node"/>
227
 
          <xsl:with-param name="role" select="$role"/>
228
 
          <xsl:with-param name="string" select="$string"/>
229
 
          <xsl:with-param name="format" select="$format"/>
230
 
        </xsl:call-template>
231
 
      </xsl:when>
232
 
      <!-- fe@fo -->
233
 
      <xsl:when test="($lang_variant) and
234
 
                      key('msg', concat($msgid, '__LC__',
235
 
                                        $lang_language, '@', $lang_variant))">
236
 
        <xsl:call-template name="l10n.gettext.msg">
237
 
          <xsl:with-param
238
 
           name="msg"
239
 
           select="key('msg', concat($msgid, '__LC__',
240
 
                                     $lang_language, '@', $lang_variant))"/>
241
 
          <xsl:with-param name="form" select="$form"/>
242
 
          <xsl:with-param name="node" select="$node"/>
243
 
          <xsl:with-param name="role" select="$role"/>
244
 
          <xsl:with-param name="string" select="$string"/>
245
 
          <xsl:with-param name="format" select="$format"/>
246
 
        </xsl:call-template>
247
 
      </xsl:when>
248
 
      <!-- fe_fi.fum -->
249
 
      <xsl:when test="($lang_region and $lang_charset) and
250
 
                      key('msg', concat($msgid, '__LC__',
251
 
                                        $lang_language, '_', $lang_region,
252
 
                                                        '.', $lang_charset))">
253
 
        <xsl:call-template name="l10n.gettext.msg">
254
 
          <xsl:with-param
255
 
           name="msg"
256
 
           select="key('msg', concat($msgid, '__LC__',
257
 
                                     $lang_language, '_', $lang_region,
258
 
                                                     '.', $lang_charset))"/>
259
 
          <xsl:with-param name="form" select="$form"/>
260
 
          <xsl:with-param name="node" select="$node"/>
261
 
          <xsl:with-param name="role" select="$role"/>
262
 
          <xsl:with-param name="string" select="$string"/>
263
 
          <xsl:with-param name="format" select="$format"/>
264
 
        </xsl:call-template>
265
 
      </xsl:when>
266
 
      <!-- fe_fi -->
267
 
      <xsl:when test="($lang_region) and
268
 
                      key('msg', concat($msgid, '__LC__',
269
 
                                        $lang_language, '_', $lang_region))">
270
 
        <xsl:call-template name="l10n.gettext.msg">
271
 
          <xsl:with-param
272
 
           name="msg"
273
 
           select="key('msg', concat($msgid, '__LC__',
274
 
                                     $lang_language, '_', $lang_region))"/>
275
 
          <xsl:with-param name="form" select="$form"/>
276
 
          <xsl:with-param name="node" select="$node"/>
277
 
          <xsl:with-param name="role" select="$role"/>
278
 
          <xsl:with-param name="string" select="$string"/>
279
 
          <xsl:with-param name="format" select="$format"/>
280
 
        </xsl:call-template>
281
 
      </xsl:when>
282
 
      <!-- fe.fum -->
283
 
      <xsl:when test="($lang_charset) and
284
 
                      key('msg', concat($msgid, '__LC__',
285
 
                                           $lang_language, '.', $lang_charset))">
286
 
        <xsl:call-template name="l10n.gettext.msg">
287
 
          <xsl:with-param
288
 
           name="msg"
289
 
           select="key('msg', concat($msgid, '__LC__',
290
 
                                     $lang_language, '.', $lang_charset))"/>
291
 
          <xsl:with-param name="form" select="$form"/>
292
 
          <xsl:with-param name="node" select="$node"/>
293
 
          <xsl:with-param name="role" select="$role"/>
294
 
          <xsl:with-param name="string" select="$string"/>
295
 
          <xsl:with-param name="format" select="$format"/>
296
 
        </xsl:call-template>
297
 
      </xsl:when>
298
 
      <!-- fe -->
299
 
      <xsl:when test="key('msg', concat($msgid, '__LC__', $lang_language))">
300
 
        <xsl:call-template name="l10n.gettext.msg">
301
 
          <xsl:with-param
302
 
           name="msg"
303
 
           select="key('msg', concat($msgid, '__LC__', $lang_language))"/>
304
 
          <xsl:with-param name="form" select="$form"/>
305
 
          <xsl:with-param name="node" select="$node"/>
306
 
          <xsl:with-param name="role" select="$role"/>
307
 
          <xsl:with-param name="string" select="$string"/>
308
 
          <xsl:with-param name="format" select="$format"/>
309
 
        </xsl:call-template>
310
 
      </xsl:when>
311
 
      <!-- "C" -->
312
 
      <xsl:when test="key('msg', concat($msgid, '__LC__C'))">
313
 
        <xsl:call-template name="l10n.gettext.msg">
314
 
          <xsl:with-param
315
 
           name="msg" select="key('msg', concat($msgid, '__LC__C'))"/>
316
 
          <xsl:with-param name="form" select="$form"/>
317
 
          <xsl:with-param name="node" select="$node"/>
318
 
          <xsl:with-param name="role" select="$role"/>
319
 
          <xsl:with-param name="string" select="$string"/>
320
 
          <xsl:with-param name="format" select="$format"/>
321
 
        </xsl:call-template>
322
 
      </xsl:when>
323
 
      <!-- not() -->
324
 
      <xsl:when test="key('msg', concat($msgid, '__LC__'))">
325
 
        <xsl:call-template name="l10n.gettext.msg">
326
 
          <xsl:with-param
327
 
           name="msg" select="key('msg', concat($msgid, '__LC__'))"/>
328
 
          <xsl:with-param name="form" select="$form"/>
329
 
          <xsl:with-param name="node" select="$node"/>
330
 
          <xsl:with-param name="role" select="$role"/>
331
 
          <xsl:with-param name="string" select="$string"/>
332
 
          <xsl:with-param name="format" select="$format"/>
333
 
        </xsl:call-template>
 
97
      <xsl:when test="$msg">
 
98
        <xsl:for-each select="$source">
 
99
          <xsl:call-template name="l10n.gettext.msg">
 
100
            <xsl:with-param name="msg" select="$msg"/>
 
101
            <xsl:with-param name="form" select="$form"/>
 
102
            <xsl:with-param name="node" select="$node"/>
 
103
            <xsl:with-param name="role" select="$role"/>
 
104
            <xsl:with-param name="string" select="$string"/>
 
105
            <xsl:with-param name="format" select="$format"/>
 
106
          </xsl:call-template>
 
107
        </xsl:for-each>
 
108
      </xsl:when>
 
109
      <xsl:when test="contains($normlang, '-')">
 
110
        <xsl:variable name="newlang">
 
111
          <xsl:for-each select="str:split($normlang, '-')[position() != last()]">
 
112
            <xsl:if test="position() != 1">
 
113
              <xsl:text>-</xsl:text>
 
114
            </xsl:if>
 
115
            <xsl:value-of select="."/>
 
116
          </xsl:for-each>
 
117
        </xsl:variable>
 
118
        <xsl:for-each select="$source">
 
119
          <xsl:call-template name="l10n.gettext">
 
120
            <xsl:with-param name="domain" select="$domain"/>
 
121
            <xsl:with-param name="msgid" select="$msgid"/>
 
122
            <xsl:with-param name="lang" select="$newlang"/>
 
123
            <xsl:with-param name="number" select="$number"/>
 
124
            <xsl:with-param name="form" select="$form"/>
 
125
            <xsl:with-param name="role" select="$role"/>
 
126
            <xsl:with-param name="string" select="$string"/>
 
127
            <xsl:with-param name="format" select="$format"/>
 
128
          </xsl:call-template>
 
129
        </xsl:for-each>
 
130
      </xsl:when>
 
131
      <xsl:when test="$normlang = 'c'">
 
132
        <xsl:value-of select="$msgid"/>
334
133
      </xsl:when>
335
134
      <xsl:otherwise>
336
 
        <xsl:message>
337
 
          <xsl:text>No translation available for string '</xsl:text>
338
 
          <xsl:value-of select="$msgid"/>
339
 
          <xsl:text>'.</xsl:text>
340
 
        </xsl:message>
341
 
        <xsl:value-of select="$msgid"/>
 
135
        <xsl:for-each select="$source">
 
136
          <xsl:call-template name="l10n.gettext">
 
137
            <xsl:with-param name="domain" select="$domain"/>
 
138
            <xsl:with-param name="msgid" select="$msgid"/>
 
139
            <xsl:with-param name="lang" select="'C'"/>
 
140
            <xsl:with-param name="number" select="$number"/>
 
141
            <xsl:with-param name="form" select="$form"/>
 
142
            <xsl:with-param name="role" select="$role"/>
 
143
            <xsl:with-param name="string" select="$string"/>
 
144
            <xsl:with-param name="format" select="$format"/>
 
145
          </xsl:call-template>
 
146
        </xsl:for-each>
342
147
      </xsl:otherwise>
343
148
    </xsl:choose>
344
149
  </xsl:for-each>
564
369
<xsl:template name="l10n.plural.form">
565
370
  <xsl:param name="number" select="1"/>
566
371
  <xsl:param name="lang" select="$l10n.locale"/>
567
 
  <xsl:param name="lang_language">
568
 
    <xsl:call-template name="l10n.language">
569
 
      <xsl:with-param name="lang" select="$lang"/>
570
 
    </xsl:call-template>
571
 
  </xsl:param>
572
 
  <xsl:param name="lang_region">
573
 
    <xsl:call-template name="l10n.region">
574
 
      <xsl:with-param name="lang" select="$lang"/>
575
 
    </xsl:call-template>
576
 
  </xsl:param>
577
 
  <xsl:param name="lang_variant">
578
 
    <xsl:call-template name="l10n.variant">
579
 
      <xsl:with-param name="lang" select="$lang"/>
580
 
    </xsl:call-template>
581
 
  </xsl:param>
582
 
  <xsl:param name="lang_charset">
583
 
    <xsl:call-template name="l10n.charset">
584
 
      <xsl:with-param name="lang" select="$lang"/>
585
 
    </xsl:call-template>
586
 
  </xsl:param>
 
372
  <xsl:variable name="normlang" select="concat(translate($lang,
 
373
                                        '_@.ABCDEFGHIJKLMNOPQRSTUVWXYZ',
 
374
                                        '---abcdefghijklmnopqrstuvwxyz'),
 
375
                                        '-')"/>
587
376
 
588
377
  <xsl:choose>
589
 
    <!--
590
 
    Keep variants first!
591
 
    When adding new languages, make sure the tests are in a format that
592
 
    can be extracted by the plurals.sh script in the i18n directory.
593
 
    -->
594
 
 
595
378
    <!-- == pt_BR == -->
596
 
    <xsl:when test="concat($lang_language, '_', $lang_region) = 'pt_BR'">
 
379
    <xsl:when test="starts-with($normlang, 'pt-br-')">
597
380
      <xsl:choose>
598
381
        <xsl:when test="$number &gt; 1">
599
382
          <xsl:text>0</xsl:text>
605
388
    </xsl:when>
606
389
 
607
390
    <!-- == ar == -->
608
 
    <xsl:when test="$lang_language = 'ar'">
 
391
    <xsl:when test="starts-with($normlang, 'ar-')">
609
392
      <xsl:choose>
610
393
        <xsl:when test="$number = 1">
611
394
          <xsl:text>0</xsl:text>
623
406
    </xsl:when>
624
407
 
625
408
    <!-- == be bs cs ru sr uk == -->
626
 
    <xsl:when test="($lang_language = 'be') or ($lang_language = 'bs') or
627
 
                    ($lang_language = 'cs') or ($lang_language = 'ru') or
628
 
                    ($lang_language = 'sr') or ($lang_language = 'uk') ">
 
409
    <xsl:when test="starts-with($normlang, 'be-') or starts-with($normlang, 'bs-') or
 
410
                    starts-with($normlang, 'cs-') or starts-with($normlang, 'ru-') or
 
411
                    starts-with($normlang, 'sr-') or starts-with($normlang, 'uk-') ">
629
412
      <xsl:choose>
630
413
        <xsl:when test="($number mod 10 = 1) and ($number mod 100 != 11)">
631
414
          <xsl:text>0</xsl:text>
740
523
l10n.direction
741
524
Determines the text direction for the language of the document
742
525
$lang: The locale to use to determine the text direction
743
 
$lang_language: The language portion of the ${lang}
744
 
$lang_region: The region portion of ${lang}
745
 
$lang_variant: The variant portion of ${lang}
746
 
$lang_charset: The charset portion of ${lang}
747
526
 
748
527
REMARK: Lots of documentation is needed
749
528
-->
750
529
<xsl:template name="l10n.direction">
751
530
  <xsl:param name="lang" select="$l10n.locale"/>
752
 
  <xsl:param name="lang_language">
753
 
    <xsl:call-template name="l10n.language">
754
 
      <xsl:with-param name="lang" select="$lang"/>
755
 
    </xsl:call-template>
756
 
  </xsl:param>
757
 
  <xsl:param name="lang_region">
758
 
    <xsl:call-template name="l10n.region">
759
 
      <xsl:with-param name="lang" select="$lang"/>
760
 
    </xsl:call-template>
761
 
  </xsl:param>
762
 
  <xsl:param name="lang_variant">
763
 
    <xsl:call-template name="l10n.variant">
764
 
      <xsl:with-param name="lang" select="$lang"/>
765
 
    </xsl:call-template>
766
 
  </xsl:param>
767
 
  <xsl:param name="lang_charset">
768
 
    <xsl:call-template name="l10n.charset">
769
 
      <xsl:with-param name="lang" select="$lang"/>
770
 
    </xsl:call-template>
771
 
  </xsl:param>
772
531
  <xsl:variable name="direction">
773
 
    <xsl:call-template name="l10n.gettext">
774
 
      <xsl:with-param name="msgid" select="'default:LTR'"/>
775
 
      <xsl:with-param name="lang" select="$lang"/>
776
 
      <xsl:with-param name="lang_language" select="$lang_language"/>
777
 
      <xsl:with-param name="lang_region"   select="$lang_region"/>
778
 
      <xsl:with-param name="lang_variant"  select="$lang_variant"/>
779
 
      <xsl:with-param name="lang_charset"  select="$lang_charset"/>
780
 
    </xsl:call-template>
 
532
    <xsl:for-each select="/*">
 
533
      <xsl:call-template name="l10n.gettext">
 
534
        <xsl:with-param name="msgid" select="'default:LTR'"/>
 
535
        <xsl:with-param name="lang" select="$lang"/>
 
536
      </xsl:call-template>
 
537
    </xsl:for-each>
781
538
  </xsl:variable>
782
539
  <xsl:choose>
783
540
    <xsl:when test="$direction = 'default:RTL'">
878
635
</xsl:template>
879
636
 
880
637
 
881
 
<!--**==========================================================================
882
 
l10n.language
883
 
Extracts the langauge portion of a locale
884
 
$lang: The locale to extract the language from
885
 
 
886
 
REMARK: Lots of documentation is needed
887
 
-->
888
 
<xsl:template name="l10n.language">
889
 
  <xsl:param name="lang" select="ancestor-or-self::*[@lang][1]/@lang |
890
 
                                 ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
891
 
  <xsl:choose>
892
 
    <xsl:when test="$lang = $l10n.locale">
893
 
      <xsl:value-of select="$l10n.language"/>
894
 
    </xsl:when>
895
 
    <xsl:when test="contains($lang, '_')">
896
 
      <xsl:value-of select="substring-before($lang, '_')"/>
897
 
    </xsl:when>
898
 
    <xsl:when test="contains($lang, '@')">
899
 
      <xsl:value-of select="substring-before($lang, '@')"/>
900
 
    </xsl:when>
901
 
    <xsl:when test="contains($lang, '_')">
902
 
      <xsl:value-of select="substring-before($lang, '@')"/>
903
 
    </xsl:when>
904
 
    <xsl:otherwise>
905
 
      <xsl:value-of select="$lang"/>
906
 
    </xsl:otherwise>
907
 
  </xsl:choose>
908
 
</xsl:template>
909
 
 
910
 
 
911
 
<!--**==========================================================================
912
 
l10n.region
913
 
Extracts the region portion of a locale
914
 
$lang: The locale to extract the region from
915
 
 
916
 
REMARK: Lots of documentation is needed
917
 
-->
918
 
<xsl:template name="l10n.region">
919
 
  <xsl:param name="lang" select="ancestor-or-self::*[@lang][1]/@lang |
920
 
                                 ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
921
 
  <xsl:choose>
922
 
    <xsl:when test="$lang = $l10n.locale">
923
 
      <xsl:value-of select="$l10n.region"/>
924
 
    </xsl:when>
925
 
    <xsl:when test="contains($lang, '_')">
926
 
      <xsl:variable name="aft" select="substring-after($lang, '_')"/>
927
 
      <xsl:choose>
928
 
        <xsl:when test="contains($aft, '@')">
929
 
          <xsl:value-of select="substring-before($aft, '@')"/>
930
 
        </xsl:when>
931
 
        <xsl:when test="contains($aft, '.')">
932
 
          <xsl:value-of select="substring-before($aft, '.')"/>
933
 
        </xsl:when>
934
 
        <xsl:otherwise>
935
 
          <xsl:value-of select="$aft"/>
936
 
        </xsl:otherwise>
937
 
      </xsl:choose>
938
 
    </xsl:when>
939
 
  </xsl:choose>
940
 
</xsl:template>
941
 
 
942
 
 
943
 
<!--**==========================================================================
944
 
l10n.variant
945
 
Extracts the variant portion of a locale
946
 
$lang: The locale to extract the variant from
947
 
 
948
 
REMARK: Lots of documentation is needed
949
 
-->
950
 
<xsl:template name="l10n.variant">
951
 
  <xsl:param name="lang" select="ancestor-or-self::*[@lang][1]/@lang |
952
 
                                 ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
953
 
  <xsl:choose>
954
 
    <xsl:when test="$lang = $l10n.locale">
955
 
      <xsl:value-of select="$l10n.variant"/>
956
 
    </xsl:when>
957
 
    <xsl:when test="contains($lang, '@')">
958
 
      <xsl:variable name="aft" select="substring-after($lang, '@')"/>
959
 
      <xsl:choose>
960
 
        <xsl:when test="contains($aft, '.')">
961
 
          <xsl:value-of select="substring-before($aft, '.')"/>
962
 
        </xsl:when>
963
 
        <xsl:otherwise>
964
 
          <xsl:value-of select="$aft"/>
965
 
        </xsl:otherwise>
966
 
      </xsl:choose>
967
 
    </xsl:when>
968
 
  </xsl:choose>
969
 
</xsl:template>
970
 
 
971
 
 
972
 
<!--**==========================================================================
973
 
l10n.charset
974
 
Extracts the charset portion of a locale
975
 
$lang: The locale to extract the charset from
976
 
 
977
 
REMARK: Lots of documentation is needed
978
 
-->
979
 
<xsl:template name="l10n.charset">
980
 
  <xsl:param name="lang" select="ancestor-or-self::*[@lang][1]/@lang |
981
 
                                 ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
982
 
  <xsl:choose>
983
 
    <xsl:when test="$lang = $l10n.locale">
984
 
      <xsl:value-of select="$l10n.charset"/>
985
 
    </xsl:when>
986
 
    <xsl:when test="contains($lang, '.')">
987
 
      <xsl:value-of select="substring-after($lang, '.')"/>
988
 
    </xsl:when>
989
 
  </xsl:choose>
990
 
</xsl:template>
991
 
 
992
 
 
993
638
<!--%%==========================================================================
994
639
l10n.format.mode
995
640
FIXME