#!/usr/bin/perl # Po4a::Dia.pm # # extract and translate translatable strings from Dia diagrams. # # This code extracts plain text from string tags on uncompressed Dia # diagrams. # # Copyright (c) 2004 by Jordi Vilalta # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## =head1 NAME Locale::Po4a::Dia - Convert uncompressed Dia diagrams from/to PO files =head1 DESCRIPTION The goal po4a [po for anything] project is to ease translations (and more interestingly, the maintenance of translation) using gettext tools on areas where they were not expected like documentation. Locale::Po4a::Dia is a module to help the translation of diagrams in the uncompressed Dia format into other [human] languages. You can get Dia (the graphical editor for these diagrams) from: http://www.gnome.org/projects/dia/ =head1 TRANSLATING WITH PO4A::DIA This module only translates uncompressed Dia diagrams. You can save your uncompressed diagrams with Dia itself, unchecking the "Compress diagram files" at the "Save Diagram" dialog. Another way is to uncompress the dia files from command line with: gunzip < original.dia > uncompressed.dia =head1 STATUS OF THIS MODULE This module is fully functional, as it relies in the Locale::Po4a::Xml module. This only defines the translateable tags (Edia:stringE), and filters the internal strings (the content of the Edia:diagramdataE tag), not interesting for translation). (NEEDS AN UPDATE) Currently it tries to get the diagram encoding from the first line (the xml declaration), and else it assumes UTF-8, and creates the .po contens in the ISO-8859-1 character set. It would be nice if it could read the command line encoding options, but I haven't watched how to do it. It uses Locale::Recode from the package libintl to recode the character sets. You can get it from http://search.cpan.org/~guido/libintl-perl-1.10/ There may be a better or more standard module to do this, but I didn't know. You're welcome to improve it. =head1 SEE ALSO L, L, L. =head1 AUTHORS Jordi Vilalta =head1 COPYRIGHT AND LICENSE Copyright (c) 2004 by Jordi Vilalta This program is free software; you may redistribute it and/or modify it under the terms of GPL (see COPYING file). =cut package Locale::Po4a::Dia2; use 5.006; use strict; use warnings; use Locale::Po4a::Xml; use vars qw(@ISA); @ISA = qw(Locale::Po4a::Xml); sub initialize { my $self = shift; my %options = @_; $self->SUPER::initialize(%options); $self->{options}{'tagsonly'}=1; $self->{options}{'tags'}.=' '; $self->treat_options; } sub found_string { my ($self,$text,$ref,$comment)=@_; #We skip the paper type string if ( $comment !~ // ) { $text =~ /^#(.*)#$/s; $text = "#".$self->translate($1,$ref,$comment, 'wrap'=>$self->{options}{'wrap'})."#"; } return $text; }