Difference between revisions of "Odt2xliff"
Jump to navigation
Jump to search
(New page: Here is a rough-and-ready script to turn the text from an ODT file into an XLIFF using Apertium and translate toolkit. <pre> #!/bin/sh APERTIUM_PATH="/home/spectre/local//bin" LTTOOLB...) |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Here is a rough-and-ready script to turn the text from an ODT file into an XLIFF using Apertium and [[translate toolkit]]. |
Here is a rough-and-ready script to turn the text from an ODT file into an XLIFF using Apertium and [[translate toolkit]]. For <code>.po</code> just remove the final call to po2xliff. |
||
<pre> |
<pre> |
||
#!/bin/sh |
#!/bin/sh |
||
APERTIUM_PATH="/home/spectre/local//bin" |
|||
LTTOOLBOX_PATH="/home/spectre/local//bin" |
|||
DEFAULT_DIRECTORY="/home/spectre/local//share/apertium" |
|||
PAIR="" |
|||
INPUT_FILE="" |
INPUT_FILE="" |
||
OUTPUT_FILE="" |
OUTPUT_FILE="" |
||
| Line 40: | Line 37: | ||
find $INPUT_TMPDIR | grep content\\.xml |\ |
find $INPUT_TMPDIR | grep content\\.xml |\ |
||
awk '{printf "<file name=\"" $0 "\"/>"; PART = $0; while(getline < PART) printf(" %s", $0); printf("\n");}' |\ |
awk '{printf "<file name=\"" $0 "\"/>"; PART = $0; while(getline < PART) printf(" %s", $0); printf("\n");}' |\ |
||
apertium-desodt |
|||
VUELVE=$(pwd) |
VUELVE=$(pwd) |
||
cd $INPUT_TMPDIR |
cd $INPUT_TMPDIR |
||
| Line 61: | Line 58: | ||
rm $TEMPO |
rm $TEMPO |
||
</pre> |
</pre> |
||
[[Category:Converters]] |
|||
Latest revision as of 17:22, 10 January 2008
Here is a rough-and-ready script to turn the text from an ODT file into an XLIFF using Apertium and translate toolkit. For .po just remove the final call to po2xliff.
#!/bin/sh
INPUT_FILE=""
OUTPUT_FILE=""
function translate_odt
{
INPUT_TMPDIR=/tmp/$$odtdir
export LC_CTYPE=$(locale -a|grep -i "utf[.]*8"|head -1);
if [[ LC_CTYPE == "" ]]
then echo "Error: Install an UTF-8 locale in your system";
exit 1;
fi
if [[ $(which zip) == "" ]]
then echo "Error: Install 'zip' command in your system";
exit 1;
fi
if [[ $(which unzip) == "" ]]
then echo "Error: Install 'unzip' command in your system";
exit 1;
fi
if [[ $FICHERO == "" ]]
then FICHERO=/tmp/$$odtorig
cat > $FICHERO
BORRAFICHERO="true"
fi
unzip -q -o -d $INPUT_TMPDIR $FICHERO
find $INPUT_TMPDIR | grep content\\.xml |\
awk '{printf "<file name=\"" $0 "\"/>"; PART = $0; while(getline < PART) printf(" %s", $0); printf("\n");}' |\
apertium-desodt
VUELVE=$(pwd)
cd $INPUT_TMPDIR
cd $VUELVE
rm -rf $INPUT_TMPDIR
}
INPUT_FILE=$1
FICHERO=$INPUT_FILE;
TEMPO=/tmp/tem.po
translate_odt |
sed 's/<\\\/text:p>/]\n\n\n\n[/g' |
python txtformat.py |
txt2po - > $TEMPO
po2xliff $TEMPO
rm $TEMPO