Embind: Test and Fix out-param handling
[LibreOffice.git] / bin / striplanguagetags.sh
blob0df4b0be522524ca9204197871d7a5905d0fb7b7
1 #!/usr/bin/env bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # take a .zip containing a flat hierarchy of odf files and strip out the
11 # language and country tags in each of them and repack it all up
12 # should convert templates so that documents based on them use
13 # the default-document-language rather than the hardcoded lang-tag
15 # All a bit hacky, but it should work
17 if [ -z "$CALLXSLTPROC" ]; then
18 echo "$0: \$CALLXSLTPROC not defined!"
19 echo "$0: Apparently we are not called from the build process, bailing out."
20 exit 1
23 tempfoo=`basename $0`
25 XSL=`mktemp /tmp/${tempfoo}.XXXXXX`
26 if [ $? -ne 0 ]; then
27 echo "$0: Can't create temp file, exiting..."
28 exit 1
31 # On Windows, xsltproc is a non-Cygwin program, so we can't pass
32 # a Cygwin /tmp path to it
33 [ "$COM" == MSC ] && XSL=`cygpath -m -s $XSL`
35 WRKDIR=`mktemp -d /tmp/${tempfoo}.XXXXXX`
36 if [ $? -ne 0 ]; then
37 echo "$0: Can't create temp dir, exiting..."
38 exit 1
41 cat > $XSL << EOF
42 <?xml version="1.0" encoding="UTF-8"?>
43 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
45 <xsl:template match="node()|@*">
46 <xsl:copy>
47 <xsl:apply-templates select="@*|node()"/>
48 </xsl:copy>
49 </xsl:template>
51 <xsl:template match="@fo:language"/>
52 <xsl:template match="@fo:country"/>
53 <xsl:template match="@fo:script"/>
54 <xsl:template match="@number:rfc-language-tag"/>
55 <xsl:template match="@style:rfc-language-tag"/>
56 <xsl:template match="@table:rfc-language-tag"/>
57 <xsl:template match="@style:rfc-language-tag-asian"/>
58 <xsl:template match="@style:rfc-language-tag-complex"/>
60 </xsl:stylesheet>
61 EOF
63 unzip -q $1 -d $WRKDIR
64 pushd $WRKDIR
65 for a in *; do
66 unzip -qc $a styles.xml > styles.tmp
67 eval "$CALLXSLTPROC -o styles.xml $XSL styles.tmp"
68 zip -qr $a styles.xml
69 rm styles.xml styles.tmp
70 done
71 popd
72 zip -qrj $1 $WRKDIR
73 rm -rf $WRKDIR
74 rm -f $XSL