Changeset 25288 for other-projects/gti

Show
Ignore:
Timestamp:
26.03.2012 17:39:57 (7 years ago)
Author:
ak19
Message:

For ease of import and export in Excel, these scripts no longer generates a spreadsheet .txt file of comma separated values but of tab separated values.

Location:
other-projects/gti
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • other-projects/gti/gti-tmx-to-spreadsheet.xsl

    r25287 r25288  
    1111       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 
    1212 
    13        3. Apply this XSLT to that XML file to obtain a unicode text file containing comma-separated values (a spreadsheet).  
     13       3. Apply this XSLT to that XML file to obtain a unicode text file containing tab-separated values (a spreadsheet).  
    1414       NOTE: Make sure the output is a *.txt file if you wish to open it in Excel without losing the unicode  
    1515       (when opened with .csv extension, the unicode is not preserved). 
     
    1717       GS2/bin/script> java -cp /research/ak19/gs2-svn/bin/java/ApplyXSLT.jar org.nzdl.gsdl.ApplyXSLT -x ../../maori/core-mi.tmx -t ../script/gti-tmx-to-spreadsheet.xsl > ../../maori/core-mi-tmx2spreadsheet.txt 
    1818 
    19        4. Translators wishing to read this text file into Excel, need to first open Excel. Then go to File > Open,  
    20        and choose to open the unicode .txt file containing the comma-separated values. 
     19       4. Translators wishing to read this text file into Excel, need to first open Excel.  
     20       Then go to File > Open, set the filetypes drop-down to show All Files *.*, 
     21       and choose to open the unicode .txt file containing the tab-separated values. 
    2122 
    2223       - A wizard will appear, allowing users to open this .txt file as a proper spreadsheet. 
     
    2526       b. in the drop down on the right, select unicode (UTF-8 or UTF-16) 
    2627       c. Click next 
    27        In the second frame of the dialog, select "comma" as the delimiter. Click Finish to open the spreadsheet data. 
     28       In the second frame of the dialog, select "tab" as the delimiter. Click Finish to open the spreadsheet data. 
    2829        
    29        5. When translators have finished working on the file, they can save it simply as an Excel spreadsheet .xls file  
    30        (File > Save As > Excel 2003 spreadsheet) and mail it back to Greenstone. 
    31        Translators are advised against saving it as a .txt 2003 Excel spreadsheet, since it doesn't seem to preserve the 
    32        comma delimiters. 
     30       5. When translators have finished working on the file, save it as an Excel spreadsheet Unicode .txt file  
     31       (through File > Save As > Excel 2003 spreadsheet > choose Unicode .txt in the file types box) 
     32       and mail this text file back to Greenstone. 
     33 
     34       6. The file returned by the translator should first be processed with the new gti-process-google-spreadsheet.pl script: 
     35       GS2/bin/script>perl -S gti-process-google-spreadsheet.pl ~/Desktop/core-mi-xml2spreadsheet-out.txt > <language>-submission.xml 
     36 
     37       Then continue processing as usual 
     38       > cat <language>-submission.xml | perl -S gti.pl submit-translations <language-code> <module-name> <username> 
     39 
    3340    --> 
    3441 
     
    4047 
    4148  <xsl:template match="tmx:body"> 
    42     <xsl:text>Source key&#44;Source text&#44;Target key&#44;Target text</xsl:text><!--column headings--> 
     49    <xsl:text>Source key&#09;Source text&#09;Target key&#09;Target text</xsl:text><!--column headings separated by tabs--> 
    4350    <xsl:text>&#10;</xsl:text> <!--newline-->   
    4451    <xsl:apply-templates select="tmx:tu"/> 
     
    5057    <xsl:text>source::</xsl:text> 
    5158    <xsl:value-of select="tmx:prop"/> 
    52     <xsl:text>&#44;</xsl:text><!-- comma --> 
     59    <xsl:text>&#09;</xsl:text><!-- tab --> 
    5360    <xsl:variable name="tempText1"><xsl:value-of select="tmx:seg"/></xsl:variable> 
    5461    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&amp;#10;&#10;", "&amp;#10;")'/> 
     
    5764    <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText4, "&amp;amp;", "&#38;")'/> 
    5865    <xsl:value-of select='$escapedText' disable-output-escaping="yes"/> 
    59     <xsl:text>&#44;</xsl:text><!-- comma --> 
     66    <xsl:text>&#09;</xsl:text><!-- tab --> 
    6067    </xsl:if> 
    6168    </xsl:for-each> 
     
    6572    <xsl:text>target::</xsl:text> 
    6673    <xsl:value-of select="tmx:prop"/> 
    67     <xsl:text>&#44;</xsl:text><!-- comma --> 
     74    <xsl:text>&#09;</xsl:text><!-- tab --> 
    6875    <xsl:variable name="tempText1"><xsl:value-of select="tmx:seg"/></xsl:variable> 
    6976    <xsl:variable name="tempText2" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, "&amp;#10;&#10;", "&amp;#10;")'/> 
  • other-projects/gti/gti-xml-to-spreadsheet.xsl

    r25287 r25288  
    88       GS2/bin/script> perl -S gti.pl get-first-n-chunks-requiring-work mi coredm 1000 > ../../macros/maori/mi-core.xml 
    99 
    10        2. Apply this XSLT to that XML file to obtain a unicode text file containing comma-separated values (a spreadsheet).  
     10       2. Apply this XSLT to that XML file to obtain a unicode text file containing tab-separated values (a spreadsheet).  
    1111       NOTE: Make sure the output is a *.txt file if you wish to open it in Excel without losing the unicode  
    1212       (when opened with .csv extension, the unicode is not preserved). 
     
    1414       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-xml-to-spreadsheet.xsl > ../../maori/core-mi-spreadsheet.txt 
    1515 
    16        3. Translators wishing to read this text file into Excel, need to first open Excel. Then go to File > Open,  
    17        and choose to open the unicode .txt file containing the comma-separated values. 
     16       3. Translators wishing to read this text file into Excel, need to first open Excel.  
     17       Then go to File > Open, set the filetypes drop-down to show All Files *.*, 
     18       and choose to open the unicode .txt file containing the tab-separated values. 
    1819 
    1920       - A wizard will appear, allowing users to open this .txt file as a proper spreadsheet. 
     
    2223       b. in the drop down on the right, select unicode (UTF-8 or UTF-16) 
    2324       c. Click next 
    24        In the second frame of the dialog, select "comma" as the delimiter. Click Finish to open the spreadsheet data. 
     25       In the second frame of the dialog, select "tab" as the delimiter. Click Finish to open the spreadsheet data. 
    2526        
    26        4. When translators have finished working on the file, they can save it simply as an Excel spreadsheet .xls file  
    27        (File > Save As > Excel 2003 spreadsheet) and mail it back to Greenstone. 
    28        Translators are advised against saving it as a .txt 2003 Excel spreadsheet, since it doesn't seem to preserve the 
    29        comma delimiters. 
     27       4. When translators have finished working on the file, save it as an Excel spreadsheet Unicode .txt file  
     28       (through File > Save As > Excel 2003 spreadsheet > choose Unicode .txt in the file types box) 
     29       and mail this text file back to Greenstone. 
     30 
     31       5. The file returned by the translator should first be processed with the new gti-process-google-spreadsheet.pl script: 
     32       GS2/bin/script>perl -S gti-process-google-spreadsheet.pl ~/Desktop/core-mi-xml2spreadsheet-out.txt > <language>-submission.xml 
     33 
     34       Then continue processing as usual 
     35       > cat <language>-submission.xml | perl -S gti.pl submit-translations <language-code> <module-name> <username> 
    3036 
    3137    --> 
     
    3440 
    3541  <xsl:template match="GTIResponse"> 
    36     <xsl:text>Key&#44;Source&#44;Target</xsl:text><!--column headings--> 
     42    <xsl:text>Key&#09;Source&#09;Target</xsl:text><!--column headings separated by tabs--> 
    3743    <xsl:text>&#10;</xsl:text> <!--newline-->   
    3844    <xsl:apply-templates select="ChunksRequiringUpdating"/> 
     
    5561  <xsl:template match="Chunk"> 
    5662    <xsl:value-of select="@key"/> 
    57     <xsl:text>&#44;</xsl:text> 
     63    <xsl:text>&#09;</xsl:text> 
    5864    <xsl:for-each select="SourceFileText"> 
    5965      <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;")'/> 
     66      <!--<xsl:variable name="tempText2" select="java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, '&#92;&#34;', '&amp;#34;')"/>--> <!-- escape (backslash-)quote with entity for quote--> 
     67      <!--<xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, ",", "&amp;#44;")'/>--> <!--Escape commas in text, as they are not CSV delimiters--> 
    6068      <xsl:value-of select='$escapedText' disable-output-escaping="yes"/> 
    6169    </xsl:for-each> 
    6270    <!--<xsl:value-of select="SourceFileText"/>--> 
    63     <xsl:text>&#44;</xsl:text> 
     71    <xsl:text>&#09;</xsl:text> 
    6472    <xsl:for-each select="TargetFileText"> 
    6573      <xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll(., "\n", "&amp;#10;")'/> 
     74      <!--<xsl:variable name="tempText2" select="java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, '&#92;&#34;', '&amp;#34;')"/>--> <!-- escape (backslash-)quote with entity for quote--> 
     75      <!--<xsl:variable name="escapedText" select='java:org.nzdl.gsdl.ApplyXSLT.replaceAll($tempText1, ",", "&amp;#44;")'/>--> <!--Escape commas in text, as they are not CSV delimiters--> 
    6676      <xsl:value-of select='$escapedText' disable-output-escaping="yes"/> 
    6777    </xsl:for-each>