root/other-projects/gti/gti-tmx-to-txt.xsl @ 31176

Revision 25287, 4.5 KB (checked in by ak19, 8 years ago)

1. Added two new XSLT files: both generate the spreadsheet .txt files necessary from the chunks of strings that still require translation work. 2. Added extensive comments into each file on how to use the 4 recently added XSLT files.

Line 
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:tmx="http://www.lisa.org/tmx14">
3  <!-- For character entities: http://www.w3.org/MarkUp/html3/latin1.html -->
4  <!-- The necessity for using xml namespaces all over and matching on namespaced element names http://www.stylusstudio.com/xsllist/200302/post70120.html -->
5
6  <!-- HOW AND WHEN TO USE THIS FILE
7       This file (obsolete) is used to produce the intermediate text file required from a translated TMX file sent in by the user. This intermediate text file, consisting of
8       2 columns of data, is then fed into the existing pipeline of processing translated spreadsheets, so that translation updates can be committed back into the GS repository.
9       
10       This assumes that the file returned by the translator is a TMX file also. In practice, this is unlikely to be the case when using GTT, since it does not allow downloading
11       of GTT files. That is why this XSLT file is obsolete.
12       However, it's use on an input TMX file is explained below.
13
14
15       1. Generate an xml file containing the chunks requiring work.
16       GS2/bin/script> perl -S gti.pl get-first-n-chunks-requiring-work mi coredm 1000 > ../../macros/maori/mi-core.xml
17
18       2. Generate a TMX file from that XML file as follows:
19       GS2/bin/script> java -cp /research/ak19/gs2-svn/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -x ../../macros/maori/mi-core.xml -t ../script/gti-generate-tmx-xml.xsl -l mi > ../../maori/core-mi.tmx
20
21       3. Once the user has finished translating, and ONLY ASSUMING the file they return is a TMX file again, apply this XSLT to obtain the .txt required:
22       GS2/bin/java>java -cp /research/ak19/gs2-svn/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -x ../../maori/core-mi.tmx -t ../script/gti-tmx-to-txt.xsl > ../../maori/core-mi.txt
23 
24 
25       4. Try processing this UTF-16 text file as before, as explained on the wiki: http://internal.greenstone.org/wiki/GTI
26
27       > perl -S gti-process-spreadsheet.pl language.txt > language-submission.xml
28       > cat language-submission.xml | perl -S gti.pl submit-translations language-code module-name username
29       (There are extra steps when GLI help files are translated, see the internal.greenstone wiki page again).
30
31    -->
32
33  <xsl:output method="text" encoding="UTF-16"/> <!-- When we save as txt from Excel, we choose UTF-16 too -->
34
35  <xsl:template match="tmx:tmx">
36    <xsl:apply-templates select="tmx:body"/>
37  </xsl:template>
38
39  <xsl:template match="tmx:body">
40    <xsl:text>Key&#09;Text</xsl:text>
41    <xsl:text>&#10;&#10;</xsl:text> <!--2 newlines--> 
42    <xsl:apply-templates select="tmx:tu"/>
43  </xsl:template>
44
45  <xsl:template match="tmx:tu">
46    <xsl:for-each select="tmx:tuv">
47      <xsl:if test="tmx:prop[@type='source']">
48    <xsl:text>source::</xsl:text>
49    <xsl:value-of select="tmx:prop"/>
50    <xsl:text>&#09;</xsl:text><!-- tab -->
51    <xsl:variable name="tempText1"><xsl:value-of select="tmx:seg"/></xsl:variable>
52    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&amp;#10;&#10;", "\n")'/>
53    <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&amp;lt;", "&#60;")'/>
54    <xsl:variable name="tempText4" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&amp;gt;", "&#62;")'/>
55    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText4, "&amp;amp;", "&#38;")'/>
56    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
57    <xsl:text>&#10;</xsl:text><!-- newline -->
58    </xsl:if>
59    </xsl:for-each>
60
61    <xsl:for-each select="tmx:tuv">
62      <xsl:if test="tmx:prop[@type='target']">
63    <xsl:text>target::</xsl:text>
64    <xsl:value-of select="tmx:prop"/>
65    <xsl:text>&#09;</xsl:text><!-- tab -->
66    <xsl:variable name="tempText1"><xsl:value-of select="tmx:seg"/></xsl:variable>
67    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&amp;#10;&#10;", "\n")'/>
68    <xsl:variable name="tempText3" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText2, "&amp;lt;", "&#60;")'/>
69    <xsl:variable name="tempText4" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText3, "&amp;gt;", "&#62;")'/>
70    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText4, "&amp;amp;", "&#38;")'/>
71    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/>
72    <xsl:text>&#10;&#10;</xsl:text><!-- 2 newlines -->
73      </xsl:if>
74    </xsl:for-each>
75  </xsl:template>
76
77</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.