Chameleon

Chameleon Svn Source Tree

Root/branches/JrCs/package/bin/po4a/lib/Locale/Po4a/Prop.pm

  • Property svn:executable set to *
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
12use Locale::Po4a::TransTractor qw(process new);
13use Locale::Po4a::Common;
14
15package Locale::Po4a::Prop;
16
17use 5.006;
18use strict;
19use warnings;
20
21require Exporter;
22
23use vars qw(@ISA @EXPORT $AUTOLOAD);
24@ISA = qw(Locale::Po4a::TransTractor);
25@EXPORT = qw();
26
27my $debug=0;
28
29sub initialize {}
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:$line\n" if $debug;
42
43if ($line =~ m/("[^"]*")[^=]*=[^"]*"(.*)/) { # "
44my @paragraph = ();
45my $pre_text = $1;
46print STDERR " PreText=".$pre_text."\n" if $debug;
47my $quoted_text = $2;
48# The text for translation
49print STDERR " QuotedText=".$quoted_text."\n" if $debug;
50 if ($quoted_text !~ /";[^"]*/) {
51@paragraph = ("$quoted_text\n");
52do {
53($line, undef) = $self->shiftline();
54push @paragraph, $line;
55} while ($line !~ /";[^"]*/);
56}
57if (@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");
68print STDERR "End of line containing \".\n" if $debug;
69}
70 else
71{
72print 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
841;
85__END__
86
87=encoding UTF-8
88
89=head1 NAME
90
91Locale::Po4a::Prop - convert Java property and OSX/NeXTSTEP strings from/to PO files
92
93=head1 DESCRIPTION
94
95Locale::Po4a::Prop is a module to help the translation of Java property and
96OSX/NeXTSTEP strings files into other [human] languages.
97
98The module searches for lines of the following format and extracts the quoted
99text:
100
101"identificator"="text than can be translated";
102
103NOTE: If the text is not quoted, it will be ignored.
104
105=head1 SEE ALSO
106
107L<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
115Copyright 2012 by Yves Blusseau
116
117This program is free software; you may redistribute it and/or modify it
118under the terms of GPL (see the COPYING file).
119
120=cut
121

Archive Download this file

Revision: 1854