1 | # Locale::Po4a::Prop -- Convert Java property and OSX/NeXTSTEP strings files␊ |
2 | # to PO file, for translation.␊ |
3 | #␊ |
4 | # This program is free software; you may redistribute it and/or modify it␊ |
5 | # under the terms of GPL (see COPYING).␊ |
6 | #␊ |
7 | ␊ |
8 | ############################################################################␊ |
9 | # Modules and declarations␊ |
10 | ############################################################################␊ |
11 | ␊ |
12 | use Locale::Po4a::TransTractor qw(process new);␊ |
13 | use Locale::Po4a::Common;␊ |
14 | ␊ |
15 | package Locale::Po4a::Prop;␊ |
16 | ␊ |
17 | use 5.006;␊ |
18 | use strict;␊ |
19 | use warnings;␊ |
20 | ␊ |
21 | require Exporter;␊ |
22 | ␊ |
23 | use vars qw(@ISA @EXPORT $AUTOLOAD);␊ |
24 | @ISA = qw(Locale::Po4a::TransTractor);␊ |
25 | @EXPORT = qw();␊ |
26 | ␊ |
27 | my $debug=0;␊ |
28 | ␊ |
29 | sub initialize {}␊ |
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:$line\n" if $debug;␊ |
42 | ␊ |
43 | ␉␉if ($line =~ m/("[^"]*")[^=]*=[^"]*"(.*)/) { # "␊ |
44 | ␉␉␉my @paragraph = ();␊ |
45 | ␉␉␉my $pre_text = $1;␊ |
46 | ␉␉␉print STDERR " PreText=".$pre_text."\n" if $debug;␊ |
47 | ␉␉␉my $quoted_text = $2;␊ |
48 | ␉␉␉# The text for translation␊ |
49 | ␉␉␉print STDERR " QuotedText=".$quoted_text."\n" if $debug;␊ |
50 | ␉␉ if ($quoted_text !~ /";[^"]*/) {␊ |
51 | ␉␉␉␉@paragraph = ("$quoted_text\n");␊ |
52 | ␉␉␉␉do {␊ |
53 | ␉␉␉␉␉($line, undef) = $self->shiftline();␊ |
54 | ␉␉␉␉␉push @paragraph, $line;␊ |
55 | ␉␉␉␉} while ($line !~ /";[^"]*/);␊ |
56 | ␉␉␉}␊ |
57 | ␉␉␉if (@paragraph) {␊ |
58 | ␉␉␉␉$quoted_text = join('', @paragraph);␊ |
59 | ␉␉␉}␊ |
60 | ␊ |
61 | ␉␉ # Remove the final ";␊ |
62 | ␉␉ $quoted_text =~ s/"\s*;[^"]*$//;␊ |
63 | ␉␉ # Translate the string␊ |
64 | ␉␉ $par = $self->translate($quoted_text, $ref, $pre_text);␊ |
65 | ␊ |
66 | ␉␉␉# Now push the result␊ |
67 | ␉␉␉$self->pushline($pre_text .' = "'.$par."\";\n");␊ |
68 | ␉␉␉print STDERR "End of line containing \".\n" if $debug;␊ |
69 | ␉␉}␊ |
70 | else␊ |
71 | ␉␉{␊ |
72 | ␉␉␉print STDERR "Other stuff\n" if $debug;␊ |
73 | ␉␉␉$self->pushline("$line\n");␊ |
74 | ␉␉}␊ |
75 | ␉␉# Reinit the loop␊ |
76 | ␉␉($line,$ref)=$self->shiftline();␊ |
77 | ␉}␊ |
78 | }␊ |
79 | ␊ |
80 | ##############################################################################␊ |
81 | # Module return value and documentation␊ |
82 | ##############################################################################␊ |
83 | ␊ |
84 | 1;␊ |
85 | __END__␊ |
86 | ␊ |
87 | =encoding UTF-8␊ |
88 | ␊ |
89 | =head1 NAME␊ |
90 | ␊ |
91 | Locale::Po4a::Prop - convert Java property and OSX/NeXTSTEP strings from/to PO files␊ |
92 | ␊ |
93 | =head1 DESCRIPTION␊ |
94 | ␊ |
95 | Locale::Po4a::Prop is a module to help the translation of Java property and␊ |
96 | OSX/NeXTSTEP strings files into other [human] languages.␊ |
97 | ␊ |
98 | The module searches for lines of the following format and extracts the quoted␊ |
99 | text:␊ |
100 | ␊ |
101 | "identificator"="text than can be translated";␊ |
102 | ␊ |
103 | NOTE: If the text is not quoted, it will be ignored.␊ |
104 | ␊ |
105 | =head1 SEE ALSO␊ |
106 | ␊ |
107 | L<Locale::Po4a::TransTractor(3pm)>, L<po4a(7)|po4a.7>␊ |
108 | ␊ |
109 | =head1 AUTHORS␊ |
110 | ␊ |
111 | Yves Blusseau <aphc549cmv@snkmail.com>␊ |
112 | ␊ |
113 | =head1 COPYRIGHT AND LICENSE␊ |
114 | ␊ |
115 | Copyright 2012 by Yves Blusseau␊ |
116 | ␊ |
117 | This program is free software; you may redistribute it and/or modify it␊ |
118 | under the terms of GPL (see the COPYING file).␊ |
119 | ␊ |
120 | =cut␊ |
121 | |