annotate tools/po4a/po4a-translate @ 728:bae6d1503482

Rename xsl to stylesheets
author Dongsheng Song <dongsheng.song@gmail.com>
date Thu, 12 Mar 2009 17:11:59 +0800
parents 082bb76417f1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 # po4a-translate -- translate doc files using a message catalog(ie, po file)
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
6 # $Id: po4a-translate,v 1.41 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-translate - convert a po file back to documentation format
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-translate -f E<lt>fmtE<gt> -m E<lt>master.docE<gt> -p E<lt>XX.poE<gt> -l E<lt>XX.docE<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.doc is the output, 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-translate> script is in charge of converting the translation
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
30 (which was done in a po file) under the documentation format back. The
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
31 provided C<po> file should be the translation of the C<pot> file which were
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
32 produced by po4a-gettextize(1).
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 =head1 OPTIONS
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
35
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
36 =over 4
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 =item -f, --format
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
39
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
40 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
41 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
42
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
43 =item -a, --addendum
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
44
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
45 Add a file to the resulting file (to put translator's name or a section
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
46 "About this translation", for example). The first line of the file to insert
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
47 should be a PO4A header indicating where it should be added (see section
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
48 I<HOWTO add extra text to translations> in po4a(7)).
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
49
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
50 =item -A, --addendum-charset
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
51
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
52 Charset of the addenda. Note that all the addenda should be in the same
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
53 charset.
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
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 File containing the master document to translate.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
58
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
59 =item -M, --master-charset
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
60
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
61 Charset of the file containing the document to translate.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
62
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
63 =item -l, --localized
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 File where the localized (translated) document should be written.
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 =item -L, --localized-charset
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
68
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
69 Charset of the file containing the localized document.
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 -p, --po
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 File from which the message catalog should be read.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
74
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
75 =item -o, --option
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
76
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
77 Extra option(s) to pass to the format plugin. Specify each option in the
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
78 'name=value' format. See the documentation of each plugin for more
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
79 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
80
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
81 =item -k, --keep
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
82
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
83 Minimal threshold for translation percentage to keep (ie, write) the
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
84 resulting file (default: 80). Ie, by default, files have to be translated
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
85 at at least 80% to get written.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
86
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
87 =item -w, --width
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
88
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
89 Column at which we should wrap the resulting file.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
90
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
91 =item -h, --help
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
92
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
93 Show a short help message.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
94
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
95 =item --help-format
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
96
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
97 List the documentation format understood by po4a.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
98
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
99 =item -V, --version
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
100
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
101 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
102
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
103 =item -v, --verbose
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
104
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
105 Increase the verbosity of the program.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
106
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
107 =item -d, --debug
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
108
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
109 Output some debugging information.
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 =back
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 =head1 Adding content (beside translations) to generated files
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 To add some extra content to the generated document beside what you
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
116 translated (like the name of the translator, or a "about this translation"
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
117 section), you should use the C<--addendum> option.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
118
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
119 The first line of the addendum must be a header indicating where to put
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
120 it in the document (it can be before or after a given part of the
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
121 document). The rest of the file will be added verbatim to the resulting
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
122 file without further processing.
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 Note that if po4a-translate fails to add one of the given files, it discards
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
125 the whole translation (because the missing file could be the one indicating
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
126 the author, what would prevent the users to contact him to report bugs in
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
127 the translation).
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
128
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
129 The header has a pretty rigid syntax. For more information on how to use
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
130 this feature and how it works, please refer to the po4a(7) man page.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
131
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
132 =head1 SEE ALSO
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
133
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
134 L<po4a(7)>, L<po4a-gettextize(1)>, L<po4a-updatepo(1)>, L<po4a-normalize(1)>.
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
135
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 =head1 AUTHORS
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
138
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
139 Denis Barbier <barbier@linuxfr.org>
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
140 Martin Quinson (mquinson#debian.org)
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 =head1 COPYRIGHT AND LICENSE
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
143
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
144 Copyright 2002, 2003, 2004 by SPI, inc.
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 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
147 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
148
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
149 =cut
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
150
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
151 use 5.006;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
152 use strict;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
153 use warnings;
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 use Locale::Po4a::Chooser;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
156 use Locale::Po4a::TransTractor;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
157 use Locale::Po4a::Common;
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 use Pod::Usage qw(pod2usage);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
160 use Getopt::Long qw(GetOptions);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
161
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
162 Locale::Po4a::Common::textdomain("po4a");
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
163
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
164 sub show_version {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
165 Locale::Po4a::Common::show_version("po4a-translate");
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
166 exit 0;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
167 }
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
168
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
169
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
170 Getopt::Long::Configure('no_auto_abbrev','no_ignore_case');
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
171 my ($outfile,$width,$threshold)=('-',80,80);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
172 my ($help,$help_fmt,@verbose,$debug,@addfiles,$format,@options);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
173 my ($master_filename,$po_filename);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
174 my ($mastchar,$locchar,$addchar);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
175 GetOptions(
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
176 'help|h' => \$help,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
177 'help-format' => \$help_fmt,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
178
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
179 'master|m=s' => \$master_filename,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
180 'localized|l=s' => \$outfile,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
181 'po|p=s' => \$po_filename,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
182 'addendum|a=s' => \@addfiles,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
183 'format|f=s' => \$format,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
184
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
185 'master-charset|M=s' => \$mastchar,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
186 'localized-charset|L=s' => \$locchar,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
187 'addendum-charset|A=s' => \$addchar,
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 'option|o=s' => \@options,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
190
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
191 'width|w=s' => \$width,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
192 'verbose|v' => \@verbose,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
193 'debug|d' => \$debug,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
194 'keep|k=s' => \$threshold,
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 'version|V' => \&show_version
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
197 ) or pod2usage();
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
198
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
199 $help && pod2usage(-verbose => 1, -exitval => 0);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
200 $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
201
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
202 (defined($master_filename) && length($master_filename))||pod2usage();
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
203 (defined($po_filename) && length($po_filename)) ||pod2usage();
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
204 -e $master_filename || die wrap_msg(gettext("File %s does not exist."), $master_filename);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
205 -e $po_filename || die wrap_msg(gettext("File %s does not exist."), $po_filename);
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 my (@pos,@masters);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
208 push @pos,$po_filename;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
209 push @masters,$master_filename;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
210
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
211 my %options = (
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
212 "verbose" => scalar @verbose,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
213 "debug" => $debug);
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 foreach (@options) {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
216 if (m/^([^=]*)=(.*)$/) {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
217 $options{$1}="$2";
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
218 } else {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
219 $options{$_}=1;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
220 }
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
221 }
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
222 # parser
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
223 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
224
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
225
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
226 # Prepare the document to be used as translator, but not parser
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
227 $doc->process('po_in_name' => \@pos,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
228 'file_in_name' => \@masters,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
229 'file_in_charset' => $mastchar,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
230 'file_out_charset' => $locchar,
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
231 'addendum_charset' => $addchar);
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 my ($percent,$hit,$queries) = $doc->stats();
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
234 my $error=0;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
235
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
236 print STDERR wrap_msg(gettext("%s is %s%% translated (%s of %s strings)."),
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
237 $master_filename, $percent, $hit, $queries)
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
238 if (scalar @verbose) && ($percent>=$threshold);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
239
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
240
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
241 if ($percent<$threshold) {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
242 print STDERR wrap_msg(gettext("Discard the translation of %s (only %s%% translated; need %s%%)."),
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
243 $master_filename, $percent, $threshold);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
244 unlink($outfile) if (-e $outfile);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
245 } else {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
246 foreach my $add (@addfiles) {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
247 unless ($doc->addendum($add)) {
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
248 unlink($outfile) if (-e $outfile);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
249 die wrap_msg(gettext("Discard the translation of %s (addendum %s does not apply)."),
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
250 $master_filename, $add);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
251 }
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
252 }
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
253 $doc->write($outfile);
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
254 }
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
255
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
256 1;
082bb76417f1 Add Po4a 0.37-dev(2009-03-08)
Dongsheng Song <dongsheng.song@gmail.com>
parents:
diff changeset
257