Chameleon

Chameleon Svn Source Tree

Root/trunk/package/bin/po4a/lib/Locale/Po4a/Dia.pm

1#!/usr/bin/perl
2
3# Po4a::Dia.pm
4#
5# extract and translate translatable strings from Dia diagrams.
6#
7# This code extracts plain text from string tags on uncompressed Dia
8# diagrams.
9#
10# Copyright (c) 2004 by Jordi Vilalta <jvprat@gmail.com>
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc.,
25# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26#
27########################################################################
28
29=encoding UTF-8
30
31=head1 NAME
32
33Locale::Po4a::Dia - convert uncompressed Dia diagrams from/to PO files
34
35=head1 DESCRIPTION
36
37The po4a (PO for anything) project goal is to ease translations (and more
38interestingly, the maintenance of translations) using gettext tools on
39areas where they were not expected like documentation.
40
41Locale::Po4a::Dia is a module to help the translation of diagrams in the
42uncompressed Dia format into other [human] languages.
43
44You can get Dia (the graphical editor for these diagrams) from:
45 http://www.gnome.org/projects/dia/
46
47=head1 TRANSLATING WITH PO4A::DIA
48
49This module only translates uncompressed Dia diagrams. You can save your
50uncompressed diagrams with Dia itself, unchecking the "Compress diagram
51files" at the "Save Diagram" dialog.
52
53Another way is to uncompress the dia files from command line with:
54 gunzip < original.dia > uncompressed.dia
55
56=head1 STATUS OF THIS MODULE
57
58This module is fully functional, as it relies in the L<Locale::Po4a::Xml>
59module. This only defines the translatable tags (E<lt>dia:stringE<gt>), and
60filters the internal strings (the content of the E<lt>dia:diagramdataE<gt>
61tag), not interesting for translation.
62
63=head1 SEE ALSO
64
65L<Locale::Po4a::TransTractor(3pm)>, L<Locale::Po4a::Xml(3pm)>, L<po4a(7)|po4a.7>
66
67=head1 AUTHORS
68
69 Jordi Vilalta <jvprat@gmail.com>
70
71=head1 COPYRIGHT AND LICENSE
72
73Copyright (c) 2004 by Jordi Vilalta <jvprat@gmail.com>
74
75This program is free software; you may redistribute it and/or modify it
76under the terms of GPL (see the COPYING file).
77
78=cut
79
80package Locale::Po4a::Dia;
81
82use 5.006;
83use strict;
84use warnings;
85
86use Locale::Po4a::Xml;
87
88use vars qw(@ISA);
89@ISA = qw(Locale::Po4a::Xml);
90
91sub initialize {
92my $self = shift;
93my %options = @_;
94
95$self->SUPER::initialize(%options);
96$self->{options}{'nostrip'}=1;
97$self->{options}{'_default_translated'}.=' <dia:string>';
98$self->treat_options;
99}
100
101sub found_string {
102my ($self,$text,$ref,$options)=@_;
103return $text if $text =~ m/^\s*$/s;
104
105#We skip the paper type string
106if ( $self->get_path() !~ /<dia:diagramdata>/ ) {
107$text =~ /^#(.*)#$/s;
108$text = "#".$self->translate($1,$ref,"String",
109'wrap'=>$self->{options}{'wrap'})."#";
110}
111
112return $text;
113}
114

Archive Download this file

Revision: 1855