-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathxliff2wxl.xsl
115 lines (95 loc) · 4.65 KB
/
xliff2wxl.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
104
105
106
107
108
109
110
111
112
113
114
115
<?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="http://schemas.microsoft.com/wix/2006/localization"
xmlns:xlf="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: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="xlf:source xlf:target"/>
<xsl:output method="xml" indent="yes" />
<xsl:template match="/xlf:xliff">
<xsl:comment>Generated by xliff2wxl on <xsl:value-of select="fn:format-dateTime(fn:current-dateTime(), '[Y0001]-[M01]-[D01]T[H01]:[m]:[s][Z]')"/></xsl:comment><xsl:text> </xsl:text>
<WixLocalization>
<xsl:if test="xlf:file/xlf:body/xlf:group[@id='language-information']/xlf:trans-unit[@id='culture-name']/xlf:target">
<xsl:variable name="target" select="xlf:file/xlf:body/xlf:group[@id='language-information']/xlf:trans-unit[@id='culture-name']/xlf:target"/>
<xsl:if test="$target/../@approved = 'yes' or
$target/@state = 'translated' or
$target/@state = 'signed-off' or
$target/@state = 'final'">
<xsl:attribute name="Culture" select="$target"/>
</xsl:if>
</xsl:if>
<xsl:if test="xlf:file/xlf:body/xlf:group[@id='language-information']/xlf:trans-unit[@id='codepage']/xlf:target">
<xsl:variable name="target" select="xlf:file/xlf:body/xlf:group[@id='language-information']/xlf:trans-unit[@id='codepage']/xlf:target"/>
<xsl:if test="$target/../@approved = 'yes' or
$target/@state = 'translated' or
$target/@state = 'signed-off' or
$target/@state = 'final'">
<xsl:attribute name="Codepage" select="$target"/>
</xsl:if>
</xsl:if>
<xsl:if test="xlf:file/xlf:body/xlf:group[@id='language-information']/xlf:trans-unit[@id='locale-id']/xlf:target">
<xsl:variable name="target" select="xlf:file/xlf:body/xlf:group[@id='language-information']/xlf:trans-unit[@id='locale-id']/xlf:target"/>
<xsl:if test="$target/../@approved = 'yes' or
$target/@state = 'translated' or
$target/@state = 'signed-off' or
$target/@state = 'final'">
<!--
Currently disabled because of a bug in WiX that will be
fixed in version 3.7
see http://sourceforge.net/p/wix/bugs/3146/
<xsl:attribute name="Language" select="$target"/>
-->
</xsl:if>
</xsl:if>
<xsl:apply-templates select="xlf:file"/>
</WixLocalization>
</xsl:template>
<xsl:template match="xlf:file">
<xsl:text> </xsl:text>
<xsl:comment>Original file: <xsl:value-of select="@original"/></xsl:comment>
<xsl:text> </xsl:text>
<xsl:apply-templates select="xlf:body"/>
</xsl:template>
<xsl:template match="xlf:body">
<xsl:apply-templates select="xlf:trans-unit|xlf:group[@id!='language-information']"/>
</xsl:template>
<xsl:template match="xlf:trans-unit[@restype!='string']">
<xsl:text> </xsl:text>
<xsl:comment>Ignored translation unit <xsl:value-of select="@id"/></xsl:comment>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="xlf:trans-unit">
<String Id="{@resname}">
<xsl:choose>
<xsl:when test="xlf:target and (
@approved = 'yes' or
xlf:target/@state = 'translated' or
xlf:target/@state = 'signed-off' or
xlf:target/@state = 'final')">
<xsl:value-of select="xlf:target"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="xlf:source"/>
</xsl:otherwise>
</xsl:choose>
</String>
</xsl:template>
</xsl:transform>