1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <!--<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">-->
|
---|
3 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java">
|
---|
4 | <!--On Translation Memory eXchange open-XML: http://www.opentag.com/tmx.htm and http://www.gala-global.org/oscarStandards/tmx/tmx14b.html
|
---|
5 | And for character entities: http://www.w3.org/MarkUp/html3/latin1.html
|
---|
6 | More information: http://xml.coverpages.org/tmxSpec971212.html#O-TMF-->
|
---|
7 |
|
---|
8 | <xsl:output method="xml" encoding="UTF-8"/>
|
---|
9 | <xsl:param name="sourcelang"/>
|
---|
10 | <xsl:param name="targetlang"/>
|
---|
11 |
|
---|
12 | <xsl:template match="GTIResponse">
|
---|
13 | <xsl:text disable-output-escaping="yes"> <!DOCTYPE tmx PUBLIC "-//LISA OSCAR:1998//DTD for Translation Memory eXchange//EN" "tmx14.dtd" > </xsl:text>
|
---|
14 |
|
---|
15 | <tmx version="1.4" xmlns="http://www.lisa.org/tmx14"><xsl:text> </xsl:text> <!--newline-->
|
---|
16 | <header
|
---|
17 | creationtool="Greenstone Translator Interface"
|
---|
18 | creationtoolversion="Greenstone2.85"
|
---|
19 | datatype="PlainText"
|
---|
20 | segtype="sentence"
|
---|
21 | adminlang="en"
|
---|
22 | srclang="{$sourcelang}"
|
---|
23 | o-tmf="GreenstoneTranslationFile"> <!--XLIFF 1.2-->
|
---|
24 | </header><xsl:text> </xsl:text> <!--newline-->
|
---|
25 | <body>
|
---|
26 | <xsl:text> </xsl:text> <!--2 newlines-->
|
---|
27 | <xsl:apply-templates select="TranslationFile"/>
|
---|
28 |
|
---|
29 |
|
---|
30 | <xsl:apply-templates select="Chunks"/>
|
---|
31 |
|
---|
32 | <xsl:apply-templates select="UptodateChunks"/>
|
---|
33 |
|
---|
34 | <!-- control the order: first all the strings needing to be updated, then all those that need translating-->
|
---|
35 | <xsl:apply-templates select="ChunksRequiringUpdating"/>
|
---|
36 | <xsl:apply-templates select="ChunksRequiringTranslation"/>
|
---|
37 | </body>
|
---|
38 | </tmx>
|
---|
39 | </xsl:template>
|
---|
40 |
|
---|
41 |
|
---|
42 | <!-- The input file contains information as follows:
|
---|
43 | <TranslationFile key="coredm" target_file_path="macros/mongolian.dm" num_chunks_translated="353" num_chunks_requiring_translation="32" num_chunks_requiring_updating="18"/>
|
---|
44 | We want this useful information to be present in the output TMX file too. Each attribute of a TranslationFile element will be a separate <prop> property value,
|
---|
45 | where the TranslationFile attribute names become the values of each property's type attribute, and the TranslationFile attribute values are the property contents.-->
|
---|
46 | <xsl:template match="TranslationFile">
|
---|
47 | <xsl:for-each select="@*">
|
---|
48 | <prop type="{name()}"><xsl:value-of select="."/></prop>
|
---|
49 | <xsl:text> </xsl:text><!--newline-->
|
---|
50 | </xsl:for-each>
|
---|
51 | </xsl:template>
|
---|
52 |
|
---|
53 | <xsl:template match="UptodateChunks">
|
---|
54 | <xsl:text> </xsl:text>
|
---|
55 | <note><xsl:text xml:lang="en">Uptodate chunks</xsl:text></note><xsl:text> </xsl:text>
|
---|
56 | <xsl:apply-templates select="Chunk">
|
---|
57 | <xsl:sort select="@key"/>
|
---|
58 | </xsl:apply-templates>
|
---|
59 | </xsl:template>
|
---|
60 |
|
---|
61 | <xsl:template match="ChunksRequiringTranslation">
|
---|
62 | <xsl:text> </xsl:text> <!--newline-->
|
---|
63 | <note><xsl:text xml:lang="en">Chunks requiring translating</xsl:text></note><xsl:text> </xsl:text> <!--newline-->
|
---|
64 | <xsl:apply-templates select="Chunk">
|
---|
65 | <xsl:sort select="@key"/>
|
---|
66 | </xsl:apply-templates>
|
---|
67 | </xsl:template>
|
---|
68 |
|
---|
69 | <xsl:template match="ChunksRequiringUpdating">
|
---|
70 | <xsl:text> </xsl:text> <!--newline-->
|
---|
71 | <note><xsl:text xml:lang="en">Chunks requiring updating</xsl:text></note><xsl:text> </xsl:text> <!--newline-->
|
---|
72 | <xsl:apply-templates select="Chunk">
|
---|
73 | <xsl:sort select="@key"/>
|
---|
74 | </xsl:apply-templates>
|
---|
75 | </xsl:template>
|
---|
76 |
|
---|
77 | <xsl:template match="Chunks">
|
---|
78 | <xsl:text> </xsl:text>
|
---|
79 | <note><xsl:text xml:lang="en">All chunks</xsl:text></note><xsl:text> </xsl:text>
|
---|
80 | <xsl:apply-templates select="Chunk">
|
---|
81 | <xsl:sort select="@key"/>
|
---|
82 | </xsl:apply-templates>
|
---|
83 | </xsl:template>
|
---|
84 |
|
---|
85 | <xsl:template match="Chunk">
|
---|
86 | <tu><xsl:text> </xsl:text> <!--newline-->
|
---|
87 | <tuv xml:lang="{$sourcelang}">
|
---|
88 | <prop type="source"><xsl:value-of select="@key"/></prop><xsl:text> </xsl:text> <!--newline-->
|
---|
89 | <seg>
|
---|
90 | <xsl:for-each select="SourceFileText">
|
---|
91 | <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&#10; ")'/>
|
---|
92 | <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "<", "&lt;")'/>
|
---|
93 | <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, ">", "&gt;")'/>
|
---|
94 | <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&", "&amp;")'/> <!-- ampersands-->
|
---|
95 | <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
|
---|
96 | </xsl:for-each>
|
---|
97 | </seg><xsl:text> </xsl:text> <!--newline-->
|
---|
98 | </tuv><xsl:text> </xsl:text> <!--newline-->
|
---|
99 | <tuv xml:lang="{$targetlang}">
|
---|
100 | <prop type="target"><xsl:value-of select="@key"/></prop><xsl:text> </xsl:text> <!--newline-->
|
---|
101 | <seg>
|
---|
102 | <xsl:for-each select="TargetFileText">
|
---|
103 | <xsl:variable name="tempText1" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&#10; ")'/>
|
---|
104 | <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "<", "&lt;")'/>
|
---|
105 | <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, ">", "&gt;")'/>
|
---|
106 | <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&", "&amp;")'/> <!-- ampersands-->
|
---|
107 | <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
|
---|
108 | </xsl:for-each>
|
---|
109 | </seg><xsl:text> </xsl:text> <!--newline-->
|
---|
110 | </tuv><xsl:text> </xsl:text> <!--newline-->
|
---|
111 | </tu><xsl:text> </xsl:text> <!--newline-->
|
---|
112 | </xsl:template>
|
---|
113 |
|
---|
114 | <!--<xsl:template match="*">Do nothing for all other templates matched</xsl:template>-->
|
---|
115 |
|
---|
116 | </xsl:stylesheet>
|
---|