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 | ␊ |
11 | use Locale::Po4a::TransTractor qw(process new);␊ |
12 | use Locale::Po4a::Common;␊ |
13 | ␊ |
14 | package Locale::Po4a::Ini;␊ |
15 | ␊ |
16 | use 5.006;␊ |
17 | use strict;␊ |
18 | use warnings;␊ |
19 | ␊ |
20 | require Exporter;␊ |
21 | ␊ |
22 | use vars qw(@ISA @EXPORT $AUTOLOAD);␊ |
23 | @ISA = qw(Locale::Po4a::TransTractor);␊ |
24 | @EXPORT = qw();␊ |
25 | ␊ |
26 | my $debug=0;␊ |
27 | ␊ |
28 | sub initialize {}␊ |
29 | ␊ |
30 | ␊ |
31 | sub parse {␊ |
32 | ␉my $self=shift;␊ |
33 | ␉my ($line,$ref);␊ |
34 | ␉my $par;␊ |
35 | ␊ |
36 | ␉LINE:␊ |
37 | ␉($line,$ref)=$self->shiftline();␊ |
38 | ␊ |
39 | ␉while (defined($line)) {␊ |
40 | ␉␉chomp($line);␊ |
41 | ␉␉print 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 | ␊ |
79 | 1;␊ |
80 | __END__␊ |
81 | ␊ |
82 | =encoding UTF-8␊ |
83 | ␊ |
84 | =head1 NAME␊ |
85 | ␊ |
86 | Locale::Po4a::Ini - convert INI files from/to PO files␊ |
87 | ␊ |
88 | =head1 DESCRIPTION␊ |
89 | ␊ |
90 | Locale::Po4a::Ini is a module to help the translation of INI files into other␊ |
91 | [human] languages.␊ |
92 | ␊ |
93 | The module searches for lines of the following format and extracts the quoted␊ |
94 | text:␊ |
95 | ␊ |
96 | identificator="text than can be translated"␊ |
97 | ␊ |
98 | NOTE: If the text is not quoted, it will be ignored.␊ |
99 | ␊ |
100 | =head1 SEE ALSO␊ |
101 | ␊ |
102 | L<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 | ␊ |
111 | Copyright 2006 by BitDefender␊ |
112 | ␊ |
113 | This program is free software; you may redistribute it and/or modify it␊ |
114 | under the terms of GPL (see the COPYING file).␊ |
115 | ␊ |
116 | =cut␊ |
117 | |