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 | ␊ |
33 | Locale::Po4a::Dia - convert uncompressed Dia diagrams from/to PO files␊ |
34 | ␊ |
35 | =head1 DESCRIPTION␊ |
36 | ␊ |
37 | The po4a (PO for anything) project goal is to ease translations (and more␊ |
38 | interestingly, the maintenance of translations) using gettext tools on␊ |
39 | areas where they were not expected like documentation.␊ |
40 | ␊ |
41 | Locale::Po4a::Dia is a module to help the translation of diagrams in the␊ |
42 | uncompressed Dia format into other [human] languages.␊ |
43 | ␊ |
44 | You 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 | ␊ |
49 | This module only translates uncompressed Dia diagrams. You can save your␊ |
50 | uncompressed diagrams with Dia itself, unchecking the "Compress diagram␊ |
51 | files" at the "Save Diagram" dialog.␊ |
52 | ␊ |
53 | Another 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 | ␊ |
58 | This module is fully functional, as it relies in the L<Locale::Po4a::Xml>␊ |
59 | module. This only defines the translatable tags (E<lt>dia:stringE<gt>), and␊ |
60 | filters the internal strings (the content of the E<lt>dia:diagramdataE<gt>␊ |
61 | tag), not interesting for translation.␊ |
62 | ␊ |
63 | =head1 SEE ALSO␊ |
64 | ␊ |
65 | L<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 | ␊ |
73 | Copyright (c) 2004 by Jordi Vilalta <jvprat@gmail.com>␊ |
74 | ␊ |
75 | This program is free software; you may redistribute it and/or modify it␊ |
76 | under the terms of GPL (see the COPYING file).␊ |
77 | ␊ |
78 | =cut␊ |
79 | ␊ |
80 | package Locale::Po4a::Dia;␊ |
81 | ␊ |
82 | use 5.006;␊ |
83 | use strict;␊ |
84 | use warnings;␊ |
85 | ␊ |
86 | use Locale::Po4a::Xml;␊ |
87 | ␊ |
88 | use vars qw(@ISA);␊ |
89 | @ISA = qw(Locale::Po4a::Xml);␊ |
90 | ␊ |
91 | sub initialize {␊ |
92 | ␉my $self = shift;␊ |
93 | ␉my %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 | ␊ |
101 | sub found_string {␊ |
102 | ␉my ($self,$text,$ref,$options)=@_;␊ |
103 | ␉return $text if $text =~ m/^\s*$/s;␊ |
104 | ␊ |
105 | ␉#We skip the paper type string␊ |
106 | ␉if ( $self->get_path() !~ /<dia:diagramdata>/ ) {␊ |
107 | ␉␉$text =~ /^#(.*)#$/s;␊ |
108 | ␉␉$text = "#".$self->translate($1,$ref,"String",␊ |
109 | ␉␉␉'wrap'=>$self->{options}{'wrap'})."#";␊ |
110 | ␉}␊ |
111 | ␊ |
112 | ␉return $text;␊ |
113 | }␊ |
114 | |