source: osm/applications/editors/josm/plugins/photoadjust/i18n/mftrans.pl@ 33512

Last change on this file since 33512 was 30180, checked in by holgermappt, 11 years ago

New language added. i18n update.

  • Property svn:executable set to *
File size: 3.1 KB
Line 
1#! /usr/bin/perl -w
2
3#####################################################################
4### http://www.perl.com/doc/manual/html/utils/pod2man.html
5### http://search.cpan.org/dist/perl/pod/perlpod.pod
6
7=head1 NAME
8
9mftrans.pl - Add the translations of the plugin description to
10 the manifest.
11
12=head1 SYNOPSIS
13
14B<poimport.pl> [B<--help>] [B<--man>] [B<--manifest> I<MANIFEST>]
15 B<--description> I<"Plugin description."> I<po/*.po> ...
16
17=head1 DESCRIPTION
18
19Read the translations of the plugin description from the specified PO
20files and add them to the manifest. Option B<--description> is
21mandatory. PO files are expected as arguments.
22
23=head1 OPTIONS
24
25=over 4
26
27=item B<--help>
28
29Prints a brief help message and exits.
30
31=item B<--man>
32
33Prints the manual page and exits.
34
35=item B<--manifest>
36
37Manifest file the translations are added to. Default is F<MANIFEST>.
38
39=item B<--description>
40
41Plugin description. The same string that is specified as
42C<plugin.description> in file F<build.xml>.
43
44=back
45
46=cut
47#####################################################################
48
49use strict;
50use utf8;
51use Encode;
52use Getopt::Long;
53use Pod::Usage;
54use File::Basename;
55push(@INC, dirname($0));
56require i18nlib;
57
58main();
59
60### Add translations of plugin description to manifest. We write an
61### ant build file and call ant to do that. This way ant will take
62### care of the manifest format details.
63sub addmfdescs($@)
64{
65 my ($manifest, $descs, @langs) = @_;
66 my $buildfile = "build-descs.xml";
67 open FILE,">",$buildfile or die "Could not open file $buildfile: $!";
68 binmode FILE, ":encoding(utf8)";
69 print FILE <<EOT;
70<?xml version="1.0" encoding="utf-8"?>
71<project name="photoadjust" default="descs" basedir=".">
72 <target name="descs">
73 <manifest file="$manifest" mode="update">
74EOT
75 foreach my $la (@langs) {
76 if (exists(${$descs}{$la})) {
77 my $trans = ${$descs}{$la};
78 print FILE " <attribute name=\"", $la,
79 "_Plugin-Description\" value=\"", $trans, "\"/>\n";
80 }
81 }
82 print FILE <<EOT;
83 </manifest>
84 </target>
85</project>
86EOT
87 close FILE;
88 system "ant -buildfile $buildfile";
89 unlink $buildfile;
90}
91
92sub main
93{
94 my $manifest = "MANIFEST"; ### Manifest file.
95 my $description = "No description."; ### Plugin description.
96 my $showhelp = 0; ### Show help screen.
97 my $showman = 0; ### Show manual page of this script.
98
99 GetOptions('help|?|h' => \$showhelp,
100 'man' => \$showman,
101 'manifest=s' => \$manifest,
102 'description=s' => \$description,
103 ) or pod2usage(2);
104
105 pod2usage(1) if $showhelp;
106 pod2usage(-exitstatus => 0, -verbose => 2) if $showman;
107
108 my %lang;
109 my @po;
110 foreach my $arg (@ARGV)
111 {
112 foreach my $f (glob $arg)
113 {
114 if($f =~ /\*/) { printf "Skipping $f\n"; }
115 elsif($f =~ /\.po$/) { push(@po, $f); }
116 else { die "unknown file extension."; }
117 }
118 }
119 exit if ($#po < 0);
120 my %data = loadfiles(\%lang,@po);
121 my $descs = $data{$description};
122 my @langs = sort keys %lang;
123 addmfdescs($manifest, $descs, @langs);
124}
Note: See TracBrowser for help on using the repository browser.