Chameleon

Chameleon Svn Source Tree

Root/tags/2.3/package/bin/po4a/lib/Locale/Po4a/Ini.pm

Source at commit 2862 created 7 years 26 days ago.
By ifabio, Tag 2.3 release, bump svn to 2.4
1# Locale::Po4a::Ini -- Convert ini files to PO file, for translation.
2#
3# This program is free software; you may redistribute it and/or modify it
4# under the terms of GPL (see COPYING).
5#
6
7############################################################################
8# Modules and declarations
9############################################################################
10
11use Locale::Po4a::TransTractor qw(process new);
12use Locale::Po4a::Common;
13
14package Locale::Po4a::Ini;
15
16use 5.006;
17use strict;
18use warnings;
19
20require Exporter;
21
22use vars qw(@ISA @EXPORT $AUTOLOAD);
23@ISA = qw(Locale::Po4a::TransTractor);
24@EXPORT = qw();
25
26my $debug=0;
27
28sub initialize {}
29
30
31sub parse {
32my $self=shift;
33my ($line,$ref);
34my $par;
35
36LINE:
37($line,$ref)=$self->shiftline();
38
39while (defined($line)) {
40chomp($line);
41print STDERR "begin\n" if $debug;
42
43 if ($line =~ /\"/) {
44 print STDERR "Start of line containing \".\n" if $debug;
45 # Text before the first quote
46 $line =~ m/(^[^"\r\n]*)"/;
47 my $pre_text = $1;
48 print STDERR " PreText=".$pre_text."\n" if $debug;
49 # The text for translation
50 $line =~ m/"([^\r\n]*)"/;
51 my $quoted_text = $1;
52 print STDERR " QuotedText=".$quoted_text."\n" if $debug;
53 # Text after last quote
54 $line =~ m/"([^"\n]*$)/;
55 my $post_text = $1;
56 print STDERR " PostText=".$post_text."\n" if $debug;
57 # Translate the string it
58 $par = $self->translate($quoted_text, $ref, $pre_text);
59 # Escape the \n characters
60 $par =~ s/\n/\\n/g;
61 # Now push the result
62 $self->pushline($pre_text.'"'.$par.'"'.$post_text."\n");
63 print STDERR "End of line containing \".\n" if $debug;
64 }
65 else
66 {
67 print STDERR "Other stuff\n" if $debug;
68 $self->pushline("$line\n");
69 }
70 # Reinit the loop
71 ($line,$ref)=$self->shiftline();
72 }
73}
74
75##############################################################################
76# Module return value and documentation
77##############################################################################
78
791;
80__END__
81
82=encoding UTF-8
83
84=head1 NAME
85
86Locale::Po4a::Ini - convert INI files from/to PO files
87
88=head1 DESCRIPTION
89
90Locale::Po4a::Ini is a module to help the translation of INI files into other
91[human] languages.
92
93The module searches for lines of the following format and extracts the quoted
94text:
95
96identificator="text than can be translated"
97
98NOTE: If the text is not quoted, it will be ignored.
99
100=head1 SEE ALSO
101
102L<Locale::Po4a::TransTractor(3pm)>, L<po4a(7)|po4a.7>
103
104=head1 AUTHORS
105
106 Razvan Rusu <rrusu@bitdefender.com>
107 Costin Stroie <cstroie@bitdefender.com>
108
109=head1 COPYRIGHT AND LICENSE
110
111Copyright 2006 by BitDefender
112
113This program is free software; you may redistribute it and/or modify it
114under the terms of GPL (see the COPYING file).
115
116=cut
117

Archive Download this file

Revision: 2862