Root/
Source at commit 2567 created 9 years 5 months ago. By ifabio, Update Chameleon pkg Installer (Allow install on ESP). (Credits to Micky1979) | |
---|---|
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 | ␉␉␉# 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");␊ |
66 | ␉␉␉print STDERR "End of line containing \".\n" if $debug;␊ |
67 | ␉␉}␊ |
68 | ␉␉else␊ |
69 | ␉␉{␊ |
70 | ␉␉␉print 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 | ␊ |
82 | 1;␊ |
83 | __END__␊ |
84 | ␊ |
85 | =encoding UTF-8␊ |
86 | ␊ |
87 | =head1 NAME␊ |
88 | ␊ |
89 | Locale::Po4a::Ini - convert INI files from/to PO files␊ |
90 | ␊ |
91 | =head1 DESCRIPTION␊ |
92 | ␊ |
93 | Locale::Po4a::Ini is a module to help the translation of INI files into other␊ |
94 | [human] languages.␊ |
95 | ␊ |
96 | The module searches for lines of the following format and extracts the quoted␊ |
97 | text:␊ |
98 | ␊ |
99 | identificator="text than can be translated"␊ |
100 | ␊ |
101 | NOTE: If the text is not quoted, it will be ignored.␊ |
102 | ␊ |
103 | =head1 SEE ALSO␊ |
104 | ␊ |
105 | L<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 | ␊ |
114 | Copyright 2006 by BitDefender␊ |
115 | ␊ |
116 | This program is free software; you may redistribute it and/or modify it␊ |
117 | under the terms of GPL (see the COPYING file).␊ |
118 | ␊ |
119 | =cut␊ |
120 |