-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwxl2xliff.xsl
103 lines (89 loc) · 4.25 KB
/
wxl2xliff.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?xml version="1.0"?>
<!--
wxl2xliff - convert WiX localization files to XLIFF using XSLT 2.0
Copyright (C) 2012 CAcert Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:transform version="2.0"
xmlns="urn:oasis:names:tc:xliff:document:1.2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:wxl="http://schemas.microsoft.com/wix/2006/localization"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform http://www.w3.org/2007/schema-for-xslt20.xsd
urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/cs02/xliff-core-1.2-strict.xsd">
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="wxl:String"/>
<xsl:output method="xml" indent="yes" />
<xsl:template match="/wxl:WixLocalization">
<xliff version="1.2">
<file original="{fn:replace(fn:base-uri(), '^.*/', '')}"
source-language="{@Culture}"
datatype="xml"
date="{fn:format-dateTime(fn:current-dateTime(),
'[Y0001]-[M01]-[D01]T[H01]:[m]:[s][Z]')}"
tool-id="wxl2xliff">
<header>
<phase-group>
<phase phase-name="extraction"
process-name="extraction"
tool-id="wxl2xliff"
date="{fn:format-dateTime(fn:current-dateTime(),
'[Y0001]-[M01]-[D01]T[H01]:[m]:[s][Z]')}"/>
</phase-group>
<tool tool-id="wxl2xliff"
tool-name="wxl2xliff"
tool-version="0.1"
tool-company="CAcert Inc."/>
</header>
<body>
<group id="language-information"
datatype="documentheader">
<trans-unit id="culture-name">
<source><xsl:value-of select="@Culture"/></source>
<note from="wxl2xliff">A Microsoft Culture Name, a string identifying the locale used. Replace with one suitable for the language you are translating into. See http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx for a list of Culture Names and corresponding codepages</note>
</trans-unit>
<trans-unit id="locale-id">
<source><xsl:value-of select="@Language"/></source>
<note from="wxl2xliff">A Microsoft Locale ID (LCID), an integer identifying the locale used. Replace with the one suitable for the language you are translating into. See http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx for a list of LCIDs</note>
</trans-unit>
<trans-unit id="codepage">
<source><xsl:value-of select="@Codepage"/></source>
<note from="wxl2xliff">A Microsoft ANSI codepage, an integer identifying the character encoding to use to represent characters in the language used. Replace with the one suitable for the language you are translating into. See http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx for a list of Culture Names and corresponding codepages</note>
</trans-unit>
</group>
<xsl:apply-templates select="wxl:String"/>
</body>
</file>
</xliff>
</xsl:template>
<xsl:template match="wxl:String">
<trans-unit id="wxl_{@Id}" resname="{@Id}" restype="string">
<source>
<!-- Mark [variable] as place holders -->
<xsl:analyze-string select="." regex="\[[^\[\]]+?\]">
<xsl:matching-substring>
<ph id="{position()}">
<xsl:value-of select="."/>
</ph>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
<xsl:fallback>
<xsl:value-of select="."/>
</xsl:fallback>
</xsl:analyze-string>
</source>
</trans-unit>
</xsl:template>
</xsl:transform>