Perl extension for writing tmx files
use XML::TMX::Writer; my $tmx = XML::TMX::Writer->new(); $tmx->start_tmx(id => 'paulojjs'); $tmx->add_tu(SRCLANG => 'en', 'en' => 'some text', 'pt' => 'algum texto'); $tmx->add_tu(SRCLANG => 'en', 'en' => 'some text', 'pt' => 'algum texto', -note => [32, 34 ], -prop => { q => 23, aut => "jj"} ); $tmx->end_tmx();
This module provides a simple way for writing \s-1TMX\s0 files.
The following methods are available:
$tmx = new XML::TMX::Writer();
Creates a new XML::TMX::Writer object
$tmx->start_tmx(-output => 'some_file.tmx');
Begins a \s-1TMX\s0 file. Several options are available:
Output of the \s-1TMX\s0, if none is defined stdout is used by default.
Tool used to create the \s-1TMX\s0. Defaults to 'XML::TMX::Writer'
Some version identification of the tool used to create the \s-1TMX\s0. Defaults to the current module version
Segment type used in the <tu> elements. Possible values are block, paragraph, sentence and phrase. Defaults to sentence.
Specifies the format of the translation memory file from which the \s-1TMX\s0 document or segment thereof have been generated.
Specifies the default language for the administrative and informative elements <note> and <prop>.
Specifies the language of the source text. If a <tu> element does not have a srclang attribute specified, it uses the one defined in the <header> element. Defaults to *all*.
Specifies the type of data contained in the element. Depending on that type, you may apply different processes to the data. The recommended values for the datatype attribute are as follow (this list is not exhaustive):
undefined
WinJoust data
Channel Definition Format
Corel \s-1CMX\s0 Format
C and \*(C+ style text
HP-Tag
\s-1HTML\s0, \s-1DHTML\s0, etc
Interleaf documents
IPF/BookMaster
Java, source and property files
JavaScript, ECMAScript scripts
Lisp
Framemaker \s-1MIF\s0, \s-1MML\s0, etc
OpenTag data
Pascal, Delphi style text
Plain text (default)
PageMaker
Rich Text Format
\s-1SGML\s0
S-Tagger for FrameMaker
S-Tagger for Interleaf
Transit data
Visual Basic scripts
Windows resources from \s-1RC\s0, \s-1DLL\s0, \s-1EXE\s0
\s-1XML\s0
Quark XPressTag
All \s-1TMX\s0 documents are in Unicode. However, it is sometimes useful to know what code set was used to encode text that was converted to Unicode for purposes of interchange. This option specifies the original or preferred code set of the data of the element in case it is to be re-encoded in a non-Unicode code set. Defaults to none.
Specifies the identifier of the user who created the element. Defaults to none.
A reference to a list of notes to be added in the header.
A reference fo a hash of properties to be added in the header. Keys are used as the \*(C`type\*(C' attribute, value as the tag contents.
$tmx->add_tu(srclang => LANG1, LANG1 => 'text1', LANG2 => 'text2'); $tmx->add_tu(srclang => LANG1, LANG1 => 'text1', LANG2 => 'text2', -note => ["value1", ## notes "value2"], -prop => { type1 => ["value1","value"], #multiple values _ => 'value2', # anonymound properties typen => ["valuen"],} );
Adds a translation unit to the \s-1TMX\s0 file. Several optional labels can be specified:
Specifies an identifier for the <tu> element. Its value is not defined by the standard (it could be unique or not, numeric or alphanumeric, etc.).
Same meaning as told in start_tmx method.
Same meaning as told in start_tmx method.
Same meaning as told in start_tmx method.
Same meaning as told in start_tmx method.
$tmx->end_tmx();
Ends the \s-1TMX\s0 file, closing file handles if necessary.
\s-1TMX\s0 Specification <http://www.lisa.org/tmx/tmx.htm>
Paulo Jorge Jesus Silva, <[email protected]>
Alberto Simo\*~es, <[email protected]>
Copyright 2003 by Projecto Natura
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.