Alberto Manuel Brandão Simões > XML-TMX-0.17 > XML::TMX::Reader

Download:
XML/XML-TMX-0.17.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.22   Source  

NAME ^

XML::TMX::Reader - Perl extension for reading TMX files

SYNOPSIS ^

   use XML::TMX::Reader;

   my $reader = XML::TMX::Reader->new( $filename );

   $reader -> for_tu( sub {
       my $tu = shift;
       #blah blah blah
   });

   @used_languages = $reader->languages;

   $reader->to_html()

DESCRIPTION ^

This module provides a simple way for reading TMX files.

METHODS ^

The following methods are available:

new

This method creates a new XML::TMX::Reader object. This process checks for the existence of the file and extracts some meta-information from the TMX header;

  my $reader = XML::TMX::Reader->new("my.tmx");

ignore_markup

This method is used to set the flag to ignore (or not) markup inside translation unit segments. The default is to ignore those markup.

If called without parameters, it sets the flag to ignore the markup. If you don't want to do that, use

  $reader->ignore_markup(0);

languages

This method returns the languages being used on the specified translation memory. Note that the module does not check for language code correctness or existence.

for_tu

Use for_tu to process all translation units from a TMX file. The first optional argument is a configuration hash. The mandatory argument to this method is a code reference. This code will be called for each translation unit found.

The configuration hash is a reference to a Perl hash. At the moment these are valid options:

output

Filename to output the changed TMX to. Note that if you use this option, your function should return a hash reference where keys are language names, and values their respective translation.

The function will receive two arguments:

If you want to process the TMX and return it again, your function should return an hash reference where keys are the languages, and values their respective translation.

for_tu2

Use for_tu2 to process all translation units from a TMX file. THis vertions iterates foa all tu (one at the time)

It will probably scale up better then for_tu

The configuration hash is a reference to a Perl hash. At the moment these are valid options:

output

Filename to output the changed TMX to. Note that if you use this option, your function should return a hash reference where keys are language names, and values their respective translation.

gen_tu

Write at most gen_tu TUs

proc_tu

Process at most proc_tu TUs

patt

Only process TU that match patt.

The function will receive two arguments:

If you want to process the TMX and return it again, your function should return an hash reference where keys are the languages, and values their respective translation.

to_html

Use this method to create a nice HTML file with the translation memories. Notice that this method is not finished yet, and relies on some images, on some specific locations.

SEE ALSO ^

XML::Writer(3), TMX Specification http://www.lisa.org/tmx/tmx.htm

AUTHOR ^

Alberto Simões, <albie@alfarrabio.di.uminho.pt>

Paulo Jorge Jesus Silva, <paulojjs@bragatel.pt>

J.João Almeida, <jj@di.uminho.pt>

COPYRIGHT AND LICENSE ^

Copyright 2003-2005 by Projecto Natura

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.