Mercurial > hgbook
annotate tools/po4a/po4a-updatepo @ 730:f7d674e6e736
Revert to original hgbook.css
author | Dongsheng Song <dongsheng.song@gmail.com> |
---|---|
date | Thu, 12 Mar 2009 17:43:30 +0800 |
parents | 082bb76417f1 |
children |
rev | line source |
---|---|
722
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
1 #! /usr/bin/env perl |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
2 eval 'exec perl -S $0 ${1+"$@"}' |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
3 if $running_under_some_shell; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
4 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
5 # pod-updatepo -- Update the po translation of POD data. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
6 # $Id: po4a-updatepo,v 1.44 2009-03-07 12:33:10 nekral-guest Exp $ |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
7 # |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
8 # Copyright 2002, 2003, 2004 by Martin Quinson (mquinson#debian.org) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
9 # |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
10 # This program is free software; you can redistribute it and/or modify it |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
11 # under the terms of GPL (see COPYING). |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
12 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
13 =head1 NAME |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
14 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
15 po4a-updatepo - update the translation (in po format) of documentation |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
16 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
17 =head1 SYNOPSIS |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
18 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
19 po4a-updatepo -f E<lt>fmtE<gt> (-m E<lt>master.docE<gt>)+ (-p E<lt>XX.poE<gt>)+ |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
20 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
21 (XX.po are the outputs, all others are inputs) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
22 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
23 =head1 DESCRIPTION |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
24 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
25 The po4a (po for anything) project goal is to ease translations (and more |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
26 interestingly, the maintenance of translations) using gettext tools on |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
27 areas where they were not expected like documentation. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
28 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
29 The C<po4a-updatepo> script is in charge of updating po files to make |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
30 them reflect the changes made to the original documentation file. For that, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
31 it converts the documentation file to a pot file, and call L<msgmerge(1)> |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
32 on this new pot and on the provided po files. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
33 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
34 It is possible to give more than one po file (if you want to update several |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
35 languages at once), and several documentation files (if you want to store |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
36 the translations of several documents in the same po file). |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
37 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
38 If the master document has non-ascii characters, it will convert the po files |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
39 to utf-8 (if they weren't already), in order to allow non-standard characters |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
40 in a culture independent way. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
41 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
42 =head1 COMMAND-LINE OPTIONS |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
43 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
44 =over 4 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
45 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
46 =item -f, --format |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
47 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
48 Format of the documentation you want to handle. Use the --help-format |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
49 option to see the list of available formats. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
50 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
51 =item -m, --master |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
52 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
53 File(s) containing the master document to translate. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
54 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
55 =item -M, --master-charset |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
56 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
57 Charset of the files containing the document to translate. Note that all |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
58 files must have the same charset. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
59 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
60 =item -p, --po |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
61 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
62 Po file(s) to update. If these files do not exist, they are created by |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
63 C<po4a-updatepo>. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
64 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
65 =item -o, --option |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
66 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
67 Extra option(s) to pass to the format plugin and other po4a internal module. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
68 Specify each option in the 'name=value' format. See the documentation of |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
69 each plugin for more information about the valid options and their meanings. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
70 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
71 =item --previous |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
72 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
73 This option adds '--previous' to the options passed to msgmerge. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
74 It requires gettext 0.16 or later. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
75 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
76 =item --msgmerge-opt options |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
77 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
78 Extra options for msgmerge. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
79 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
80 =item -h, --help |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
81 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
82 Show a short help message. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
83 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
84 =item --help-format |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
85 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
86 List the documentation format handled by po4a. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
87 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
88 =item -V, --version |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
89 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
90 Display the version of the script and exit. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
91 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
92 =item -v, --verbose |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
93 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
94 Increase the verbosity of the program. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
95 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
96 =item -d, --debug |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
97 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
98 Output some debugging information. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
99 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
100 =back |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
101 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
102 =head1 SEE ALSO |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
103 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
104 L<po4a(7)>, L<po4a-gettextize(1)>, L<po4a-translate(1)>, L<po4a-normalize(1)>. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
105 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
106 =head1 AUTHORS |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
107 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
108 Denis Barbier <barbier@linuxfr.org> |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
109 Martin Quinson (mquinson#debian.org) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
110 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
111 =head1 COPYRIGHT AND LICENSE |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
112 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
113 Copyright 2002, 2003, 2004, 2005 by SPI, inc. |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
114 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
115 This program is free software; you may redistribute it and/or modify it |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
116 under the terms of GPL (see the COPYING file). |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
117 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
118 =cut |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
119 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
120 use 5.006; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
121 use strict; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
122 use warnings; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
123 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
124 use Getopt::Long qw(GetOptions); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
125 use Locale::Po4a::Po; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
126 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
127 use Locale::Po4a::Chooser; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
128 use Locale::Po4a::TransTractor; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
129 use Locale::Po4a::Common; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
130 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
131 use Pod::Usage qw(pod2usage); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
132 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
133 use File::Temp; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
134 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
135 Locale::Po4a::Common::textdomain('po4a'); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
136 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
137 sub show_version { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
138 Locale::Po4a::Common::show_version("po4a-updatepo"); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
139 exit 0; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
140 } |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
141 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
142 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
143 # init commandline parser |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
144 Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev'); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
145 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
146 # Parse our options |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
147 my (@masterfiles,@pofiles); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
148 my ($help,$help_fmt,$verbose,$debug,$format,@options); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
149 my $mastchar; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
150 my $previous; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
151 my $msgmerge_opt = ""; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
152 GetOptions('help|h' => \$help, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
153 'help-format' => \$help_fmt, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
154 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
155 'master|m=s' => \@masterfiles, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
156 'po|p=s' => \@pofiles, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
157 'format|f=s' => \$format, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
158 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
159 'master-charset|M=s' => \$mastchar, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
160 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
161 'option|o=s' => \@options, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
162 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
163 'previous' => \$previous, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
164 'msgmerge-opt=s' => \$msgmerge_opt, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
165 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
166 'verbose|v' => \$verbose, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
167 'debug|d' => \$debug, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
168 'version|V' => \&show_version) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
169 or pod2usage(); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
170 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
171 $help && pod2usage (-verbose => 1, -exitval => 0); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
172 $help_fmt && Locale::Po4a::Chooser::list(0); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
173 pod2usage () if scalar @masterfiles < 1 || scalar @pofiles < 1; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
174 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
175 $msgmerge_opt .= " --previous" if $previous; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
176 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
177 my %options = ( |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
178 "verbose" => $verbose, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
179 "debug" => $debug); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
180 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
181 foreach (@options) { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
182 if (m/^([^=]*)=(.*)$/) { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
183 $options{$1}="$2"; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
184 } else { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
185 $options{$_}=1; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
186 } |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
187 } |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
188 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
189 # parser |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
190 my ($doc)=Locale::Po4a::Chooser::new($format,%options); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
191 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
192 map { -e $_ || die wrap_msg(gettext("File %s does not exist."), $_) } @masterfiles; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
193 map { die wrap_msg(gettext("po4a-updatepo can't take the input po from stdin.")) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
194 if $_ eq '-' && !-e '-'} @pofiles; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
195 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
196 my ($pot_filename); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
197 (undef,$pot_filename)=File::Temp->tempfile("po4a-updatepoXXXX", |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
198 DIR => "/tmp", |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
199 SUFFIX => ".pot", |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
200 OPEN => 0, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
201 UNLINK => 0) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
202 or die wrap_msg(gettext("Can't create a temporary pot file: %s"), $!); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
203 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
204 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
205 print STDERR wrap_msg(gettext("Parse input files... ")) if $verbose; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
206 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
207 $doc->{TT}{utf_mode} = 1; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
208 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
209 $doc->process('file_in_name' => \@masterfiles, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
210 'file_in_charset' => $mastchar, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
211 'po_out_name' => $pot_filename, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
212 'debug' => $debug, |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
213 'verbose' => $verbose); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
214 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
215 print STDERR wrap_msg(gettext("done.")) if $verbose; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
216 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
217 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
218 while (my $po_filename=shift @pofiles) { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
219 if (-e $po_filename) { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
220 print STDERR wrap_msg(gettext("Updating %s:"), $po_filename) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
221 if $verbose; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
222 my $cmd = "msgmerge $msgmerge_opt -U $po_filename $pot_filename"; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
223 system ($cmd) == 0 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
224 or die wrap_msg(gettext("Error while running msgmerge: %s"), $!); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
225 system "msgfmt --statistics -v -o /dev/null $po_filename" |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
226 if $verbose; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
227 } else { |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
228 print STDERR wrap_msg(gettext("Creating %s:"), $po_filename) |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
229 if $verbose; |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
230 system ("cp",$pot_filename,$po_filename) == 0 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
231 or die wrap_msg(gettext("Error while copying the po file: %s"), $!); |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
232 } |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
233 } |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
234 |
082bb76417f1
Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff
changeset
|
235 unlink($pot_filename); |