Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/package/bin/po4a/lib/Locale/Po4a/Ini.pm

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
43if ($line =~ /\"/) {
44print STDERR "Start of line containing \".\n" if $debug;
45# Text before the first quote
46$line =~ m/(^[^"\r\n]*")/;
47my $pre_text = $1;
48print STDERR " PreText=".$pre_text."\n" if $debug;
49# The text for translation
50$line =~ m/("[^\r\n]*")/;
51my $quoted_text = $1;
52print STDERR " QuotedText=".$quoted_text."\n" if $debug;
53# Text after last quote
54$line =~ m/("[^"\n]*$)/;
55my $post_text = $1;
56print STDERR " PostText=".$post_text."\n" if $debug;
57# Remove starting and ending quotes from the translation text, if any
58$quoted_text =~ s/^"//g;
59$quoted_text =~ s/"$//g;
60# Translate the string it
61$par = $self->translate($quoted_text, $ref);
62# Escape the \n characters
63$par =~ s/\n/\\n/g;
64# Now push the result
65$self->pushline($pre_text.$par.$post_text."\n");
66print STDERR "End of line containing \".\n" if $debug;
67}
68else
69{
70print STDERR "Other stuff\n" if $debug;
71$self->pushline("$line\n");
72}
73# Reinit the loop
74($line,$ref)=$self->shiftline();
75}
76}
77
78##############################################################################
79# Module return value and documentation
80##############################################################################
81
821;
83__END__
84
85=encoding UTF-8
86
87=head1 NAME
88
89Locale::Po4a::Ini - convert INI files from/to PO files
90
91=head1 DESCRIPTION
92
93Locale::Po4a::Ini is a module to help the translation of INI files into other
94[human] languages.
95
96The module searches for lines of the following format and extracts the quoted
97text:
98
99identificator="text than can be translated"
100
101NOTE: If the text is not quoted, it will be ignored.
102
103=head1 SEE ALSO
104
105L<Locale::Po4a::TransTractor(3pm)>, L<po4a(7)|po4a.7>
106
107=head1 AUTHORS
108
109 Razvan Rusu <rrusu@bitdefender.com>
110 Costin Stroie <cstroie@bitdefender.com>
111
112=head1 COPYRIGHT AND LICENSE
113
114Copyright 2006 by BitDefender
115
116This program is free software; you may redistribute it and/or modify it
117under the terms of GPL (see the COPYING file).
118
119=cut
120

Archive Download this file

Revision: 1847