1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Rename accelerator checking scripts.

This commit is contained in:
Kalle Olavi Niemitalo 2007-07-17 14:32:07 +03:00 committed by Kalle Olavi Niemitalo
parent 6117f8a164
commit e6a2430fb7
5 changed files with 93 additions and 99 deletions

View File

@ -46,8 +46,8 @@ HTML_DOCS-$(CONFIG_POD2HTML) += \
# Don't install these documents, because the corresponding scripts # Don't install these documents, because the corresponding scripts
# are not installed either. However, generating them may be useful. # are not installed either. However, generating them may be useful.
HTML_DOCS_NOINSTALL-$(CONFIG_POD2HTML) += \ HTML_DOCS_NOINSTALL-$(CONFIG_POD2HTML) += \
perl-check-accelerator-conflicts.html \ perl-msgaccel-check.html \
perl-gather-accelerator-contexts.html perl-msgaccel-prepare.html
MAN_DOCS-$(CONFIG_XMLTO) += \ MAN_DOCS-$(CONFIG_XMLTO) += \
elinks.1 \ elinks.1 \

View File

@ -53,7 +53,7 @@ $(srcdir)$(POTFILES_ABS_LIST): $(POTFILES_REL)
find src/ -type f -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort ) \ find src/ -type f -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort ) \
> $(srcdir)$(POTFILES_ABS_LIST) > $(srcdir)$(POTFILES_ABS_LIST)
$(srcdir)$(PACKAGE).pot: $(srcdir)$(POTFILES_ABS_LIST) $(srcdir)perl/gather-accelerator-contexts.pl $(srcdir)$(PACKAGE).pot: $(srcdir)$(POTFILES_ABS_LIST) $(srcdir)perl/msgaccel-prepare
$(XGETTEXT) --default-domain=$(PACKAGE) \ $(XGETTEXT) --default-domain=$(PACKAGE) \
--directory=$(top_srcdir) \ --directory=$(top_srcdir) \
--add-comments --language=C \ --add-comments --language=C \
@ -77,7 +77,7 @@ $(srcdir)$(PACKAGE).pot: $(srcdir)$(POTFILES_ABS_LIST) $(srcdir)perl/gather-acce
--flag=N__:1:pass-c-format \ --flag=N__:1:pass-c-format \
-f $(srcdir)$(POTFILES_ABS_LIST) \ -f $(srcdir)$(POTFILES_ABS_LIST) \
&& test -f $(PACKAGE).po \ && test -f $(PACKAGE).po \
&& $(PERL) -I"$(srcdir)perl" $(srcdir)perl/gather-accelerator-contexts.pl -S"$(top_srcdir)" $(PACKAGE).po \ && $(PERL) -I"$(srcdir)perl" $(srcdir)perl/msgaccel-prepare -S"$(top_srcdir)" $(PACKAGE).po \
&& mv -f $(PACKAGE).po $(srcdir)$(PACKAGE).pot && mv -f $(PACKAGE).po $(srcdir)$(PACKAGE).pot
@ -111,7 +111,7 @@ check-po:
@-$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \ @-$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
echo -n "$(lang): "; \ echo -n "$(lang): "; \
$(GMSGFMT) --check --check-accelerators="~" --verbose --statistics -o /dev/null $(srcdir)$(lang).po; \ $(GMSGFMT) --check --check-accelerators="~" --verbose --statistics -o /dev/null $(srcdir)$(lang).po; \
$(PERL) -I"$(srcdir)perl" $(srcdir)perl/check-accelerator-conflicts.pl $(srcdir)$(lang).po; \ $(PERL) -I"$(srcdir)perl" $(srcdir)perl/msgaccel-check $(srcdir)$(lang).po; \
) )
### Installation and distribution ### Installation and distribution

View File

@ -21,21 +21,21 @@ When a programmer adds a translatable string to the C source code of
ELinks, and the string contains an accelerator, he should also add a ELinks, and the string contains an accelerator, he should also add a
special "gettext_accelerator_context" comment that names the menu or special "gettext_accelerator_context" comment that names the menu or
dialog box in which the string will be used. See the documentation of dialog box in which the string will be used. See the documentation of
gather-accelerator-contexts.pl for the details. msgaccel-prepare for the details.
When a programmer or translator runs "make update-po" in the When a programmer or translator runs "make update-po" in the elinks/po
elinks/po directory, gather-accelerator-contexts.pl reads the directory, msgaccel-prepare reads the "gettext_accelerator_context"
"gettext_accelerator_context" comments in the source files and comments in the source files and generates "accelerator_context"
generates "accelerator_context" comments in elinks.pot. Then, comments in elinks.pot. Then, msgmerge copies them from elinks.pot to
msgmerge copies them from elinks.pot to *.po. *.po.
When a translator edits a *.po file, she does not alter the When a translator edits a *.po file, she does not alter the
"accelerator_context" comments. "accelerator_context" comments.
When a translator runs "make check-po" in the elinks/po directory, When a translator runs "make check-po" in the elinks/po directory,
check-accelerator-conflicts.pl reads the "accelerator_context" msgaccel-check reads the "accelerator_context" comments in the *.po
comments in the *.po file, checks the accelerators in the file, checks the accelerators in the translations, and displays any
translations, and displays any conflicts it finds. conflicts it finds.
FILES FILES
@ -43,12 +43,12 @@ FILES
See each file for copying conditions. See each file for copying conditions.
gather-accelerator-contexts.pl reads elinks.pot and the source files msgaccel-prepare reads elinks.pot and the source files to which it
to which it refers, and writes a new elinks.pot with information from refers, and writes a new elinks.pot with information from
"gettext_accelerator_context" comments. "gettext_accelerator_context" comments.
check-accelerator-conflicts.pl reads just one *.po file and scans it msgaccel-check reads just one *.po file and scans it for conflicts.
for conflicts. It does not access the C source files. It does not access the C source files.
Locale/PO.pm was originally imported from Locale-PO-0.16 on CPAN, and Locale/PO.pm was originally imported from Locale-PO-0.16 on CPAN, and
has since been patched to make it more suitable for these scripts. has since been patched to make it more suitable for these scripts.

View File

@ -7,11 +7,11 @@ use Locale::PO qw();
use Getopt::Long qw(GetOptions :config bundling gnu_compat); use Getopt::Long qw(GetOptions :config bundling gnu_compat);
use autouse 'Pod::Usage' => qw(pod2usage); use autouse 'Pod::Usage' => qw(pod2usage);
my $VERSION = "1.5"; my $VERSION = "1.6";
sub show_version sub show_version
{ {
print "check-accelerator-conflicts.pl $VERSION\n"; print "msgaccel-check $VERSION\n";
pod2usage({-verbose => 99, -sections => "COPYRIGHT AND LICENSE", pod2usage({-verbose => 99, -sections => "COPYRIGHT AND LICENSE",
-exitval => 0}); -exitval => 0});
} }
@ -208,32 +208,31 @@ __END__
=head1 NAME =head1 NAME
check-accelerator-conflicts.pl - Scan a PO file for conflicting msgaccel-check - Scan a PO file for conflicting accelerator keys.
accelerator keys.
=head1 SYNOPSIS =head1 SYNOPSIS
B<check-accelerator-conflicts.pl> [I<option> ...] F<I<language>.po> [...] B<msgaccel-check> [I<option> ...] F<I<language>.po> [...]
=head1 DESCRIPTION =head1 DESCRIPTION
B<check-accelerator-conflicts.pl> is part of a framework that detects B<msgaccel-check> is part of a framework that detects conflicting
conflicting accelerator keys in Gettext PO files. A conflict is when accelerator keys in Gettext PO files. A conflict is when two items in
two items in the same menu or two buttons in the same dialog box use the same menu or two buttons in the same dialog box use the same
the same accelerator key. accelerator key.
The PO file format does not normally include any information on which The PO file format does not normally include any information on which
strings will be used in the same menu or dialog box. strings will be used in the same menu or dialog box.
B<check-accelerator-conflicts.pl> can only be used on PO files to which B<msgaccel-check> can only be used on PO files to which this
this information has been added with B<gather-accelerator-contexts.pl> information has been added with B<msgaccel-prepare> or merged with
or merged with B<msgmerge>. B<msgmerge>.
B<check-accelerator-conflicts.pl> reads the F<I<language>.po> file B<msgaccel-check> reads the F<I<language>.po> file named on the
named on the command line and reports any conflicts to standard error. command line and reports any conflicts to standard error. It also
It also tries to suggest replacements for the conflicting accelerators. tries to suggest replacements for the conflicting accelerators.
B<check-accelerator-conflicts.pl> does not access the source files to B<msgaccel-check> does not access the source files to which
which F<I<language>.po> refers. Thus, it does not matter if the line F<I<language>.po> refers. Thus, it does not matter if the line
numbers in "#:" lines are out of date. numbers in "#:" lines are out of date.
=head1 OPTIONS =head1 OPTIONS
@ -243,10 +242,9 @@ numbers in "#:" lines are out of date.
=item B<--accelerator-tag=>I<character> =item B<--accelerator-tag=>I<character>
Specify the character that marks accelerators in C<msgstr> strings. Specify the character that marks accelerators in C<msgstr> strings.
Whenever this character occurs in a C<msgstr>, Whenever this character occurs in a C<msgstr>, B<msgaccel-check>
B<check-accelerator-conflicts.pl> treats the next character as an treats the next character as an accelerator and checks that it is
accelerator and checks that it is unique in each of the contexts in unique in each of the contexts in which the C<msgstr> is used.
which the C<msgstr> is used.
Omitting the B<--accelerator-tag> option implies Omitting the B<--accelerator-tag> option implies
B<--accelerator-tag="~">. The option must be given to each program B<--accelerator-tag="~">. The option must be given to each program
@ -258,14 +256,13 @@ in the PO file.
=item B<--no-msgid-fallback> =item B<--no-msgid-fallback>
Select how to check entries where the C<msgstr> is missing or fuzzy. Select how to check entries where the C<msgstr> is missing or fuzzy.
The default is B<--msgid-fallback>, which makes The default is B<--msgid-fallback>, which makes B<msgaccel-check> use
B<check-accelerator-conflicts.pl> use the C<msgid> instead, and report the C<msgid> instead, and report any conflicts between C<msgid> and
any conflicts between C<msgid> and C<msgstr> strings. The alternative C<msgstr> strings. The alternative is B<--no-msgid-fallback>, which
is B<--no-msgid-fallback>, which makes B<check-accelerator-conflicts.pl> makes B<msgaccel-check> completely ignore such entries.
completely ignore such entries.
Regardless of these options, B<check-accelerator-conflicts.pl> will Regardless of these options, B<msgaccel-check> will suggest
suggest accelerators that would conflict with ones defined in C<msgid> accelerators that would conflict with ones defined in C<msgid>
strings. Those strings will be eventually shadowed by C<msgstr> strings. Those strings will be eventually shadowed by C<msgstr>
strings, so their accelerators should not affect which accelerators strings, so their accelerators should not affect which accelerators
the translator chooses for C<msgstr> strings. the translator chooses for C<msgstr> strings.
@ -278,8 +275,8 @@ the translator chooses for C<msgstr> strings.
=item F<I<language>.po> [...] =item F<I<language>.po> [...]
The PO files to be scanned for conflicts. These files must include the The PO files to be scanned for conflicts. These files must include
"accelerator_context" comments added by B<gather-accelerator-contexts.pl>. the "accelerator_context" comments added by B<msgaccel-prepare>.
If the special comments are missing, no conflicts will be found. If the special comments are missing, no conflicts will be found.
=back =back
@ -296,9 +293,9 @@ If the special comments are missing, no conflicts will be found.
=head2 Waiting for Locale::PO fixes =head2 Waiting for Locale::PO fixes
When B<check-accelerator-conflicts.pl> includes C<msgstr> strings in When B<msgaccel-check> includes C<msgstr> strings in warnings, it
warnings, it should transcode them from the charset of the PO file to should transcode them from the charset of the PO file to the one
the one specified by the user's locale. specified by the user's locale.
=head1 AUTHOR =head1 AUTHOR
@ -335,4 +332,4 @@ DEALINGS IN THE SOFTWARE.
=head1 SEE ALSO =head1 SEE ALSO
L<gather-accelerator-contexts.pl>, C<xgettext(1)>, C<msgmerge(1)> L<msgaccel-prepare>, C<xgettext(1)>, C<msgmerge(1)>

View File

@ -8,11 +8,11 @@ use Getopt::Long qw(GetOptions :config bundling gnu_compat);
use autouse 'Pod::Usage' => qw(pod2usage); use autouse 'Pod::Usage' => qw(pod2usage);
use autouse 'File::Spec::Functions' => qw(catfile); use autouse 'File::Spec::Functions' => qw(catfile);
my $VERSION = "1.1"; my $VERSION = "1.2";
sub show_version sub show_version
{ {
print "gather-accelerator-contexts.pl $VERSION\n"; print "msgaccel-prepare $VERSION\n";
pod2usage({-verbose => 99, -sections => "COPYRIGHT AND LICENSE", pod2usage({-verbose => 99, -sections => "COPYRIGHT AND LICENSE",
-exitval => 0}); -exitval => 0});
} }
@ -168,24 +168,24 @@ __END__
=head1 NAME =head1 NAME
gather-accelerator-contexts.pl - Augment a PO file with information msgaccel-prepare - Augment a PO file with information for detecting
for detecting accelerator conflicts. accelerator conflicts.
=head1 SYNOPSIS =head1 SYNOPSIS
B<gather-accelerator-contexts.pl> [I<option> ...] F<I<program>.pot> B<msgaccel-prepare> [I<option> ...] F<I<program>.pot>
=head1 DESCRIPTION =head1 DESCRIPTION
B<gather-accelerator-contexts.pl> is part of a framework that detects B<msgaccel-prepare> is part of a framework that detects conflicting
conflicting accelerator keys in Gettext PO files. A conflict is when accelerator keys in Gettext PO files. A conflict is when two items in
two items in the same menu or two buttons in the same dialog box use the same menu or two buttons in the same dialog box use the same
the same accelerator key. accelerator key.
The PO file format does not normally include any information on which The PO file format does not normally include any information
strings will be used in the same menu or dialog box. on which strings will be used in the same menu or dialog box.
B<gather-accelerator-contexts.pl> adds this information in the form of B<msgaccel-prepare> adds this information in the form of
"accelerator_context" comments, which B<check-accelerator-conflicts.pl> "accelerator_context" comments, which B<msgaccel-check>
then parses in order to detect the conflicts. then parses in order to detect the conflicts.
The PO file format also does not directly support definitions of The PO file format also does not directly support definitions of
@ -194,17 +194,17 @@ strings, by placing a tilde in front of the character that should be
used as the accelerator key. That is also the syntax supported by used as the accelerator key. That is also the syntax supported by
this framework and by B<msgfmt --check-accelerators> of GNU Gettext. this framework and by B<msgfmt --check-accelerators> of GNU Gettext.
B<gather-accelerator-contexts.pl> first reads the F<I<program>.pot> B<msgaccel-prepare> first reads the F<I<program>.pot> file named on
file named on the command line. This file must include "#:" comments the command line. This file must include "#:" comments that point
that point to the source files from which B<xgettext> extracted each to the source files from which B<xgettext> extracted each C<msgid>.
C<msgid>. B<gather-accelerator-contexts.pl> then scans those source B<msgaccel-prepare> then scans those source files for context
files for context information and rewrites F<I<program>.pot> to information and rewrites F<I<program>.pot> to include the
include the "accelerator_context" comments. Finally, the standard "accelerator_context" comments. Finally, the standard tool
tool B<msgmerge> can be used to copy the added comments to all the B<msgmerge> can be used to copy the added comments to all the
F<I<language>.po> files. F<I<language>.po> files.
It is best to run B<gather-accelerator-contexts.pl> immediately after It is best to run B<msgaccel-prepare> immediately after B<xgettext>
B<xgettext> so that the source references will be up to date. so that the source references will be up to date.
=head2 Contexts =head2 Contexts
@ -249,17 +249,16 @@ formatted like this:
[gettext_accelerator_context()] [gettext_accelerator_context()]
ends the region. */ ends the region. */
B<gather-accelerator-contexts.pl> removes from F<I<program>.pot> any B<msgaccel-prepare> removes from F<I<program>.pot> any
"gettext_accelerator_context" comments that B<xgettext --add-comments> "gettext_accelerator_context" comments that B<xgettext --add-comments>
may have copied there. may have copied there.
B<gather-accelerator-contexts.pl> warns if it does not find any B<msgaccel-prepare> warns if it does not find any contexts for some
contexts for some use of an C<msgid> that contains the character use of an C<msgid> that contains the character specified with the
specified with the B<--accelerator-tag> option. If the character does B<--accelerator-tag> option. If the character does not actually
not actually indicate an accelerator in that C<msgid> (e.g. "~" in indicate an accelerator in that C<msgid> (e.g. "~" in "~/.bashrc"),
"~/.bashrc"), the warning can be silenced by specifying the special the warning can be silenced by specifying the special context
context "IGNORE", which B<gather-accelerator-contexts.pl> otherwise "IGNORE", which B<msgaccel-prepare> otherwise ignores.
ignores.
=head1 OPTIONS =head1 OPTIONS
@ -270,15 +269,14 @@ B<--source-directory=>F<I<srcdir>>
The directory to which the source references in "#:" lines are The directory to which the source references in "#:" lines are
relative. Each use of this option adds one directory to the search relative. Each use of this option adds one directory to the search
path. If you do not specify this option, path. If you do not specify this option, B<msgaccel-prepare>
B<gather-accelerator-contexts.pl> implicitly searches the current implicitly searches the current directory.
directory.
=item B<--accelerator-tag=>I<character> =item B<--accelerator-tag=>I<character>
Specify the character that marks accelerators in C<msgid> strings. Specify the character that marks accelerators in C<msgid> strings.
B<gather-accelerator-contexts.pl> looks up accelerator contexts for B<msgaccel-prepare> looks up accelerator contexts for any C<msgid>
any C<msgid> that contains this character. that contains this character.
Omitting the B<--accelerator-tag> option implies Omitting the B<--accelerator-tag> option implies
B<--accelerator-tag="~">. The option must be given to each program B<--accelerator-tag="~">. The option must be given to each program
@ -293,24 +291,23 @@ in the PO file.
=item F<I<program>.pot> =item F<I<program>.pot>
The file to augment with context information. The file to augment with context information. B<msgaccel-prepare>
B<gather-accelerator-contexts.pl> first reads this file and then first reads this file and then overwrites it.
overwrites it.
Although this documentation keeps referring to F<I<program>.pot>, Although this documentation keeps referring to F<I<program>.pot>,
you can also use B<gather-accelerator-contexts.pl> on an already you can also use B<msgaccel-prepare> on an already translated
translated F<I<language>.po>. However, that will only work correctly F<I<language>.po>. However, that will only work correctly if the
if the source references in the "#:" lines are still up to date. source references in the "#:" lines are still up to date.
=back =back
=head1 BUGS =head1 BUGS
B<gather-accelerator-contexts.pl> assumes that source files are in B<msgaccel-prepare> assumes that source files are in the C programming
the C programming language: specifically, that a closing brace at language: specifically, that a closing brace at the beginning of a
the beginning of a line marks the end of a function. line marks the end of a function.
B<gather-accelerator-contexts.pl> doesn't check whether the B<msgaccel-prepare> doesn't check whether the
"gettext_accelerator_context" comments actually are comments. "gettext_accelerator_context" comments actually are comments.
=head1 AUTHOR =head1 AUTHOR
@ -348,4 +345,4 @@ DEALINGS IN THE SOFTWARE.
=head1 SEE ALSO =head1 SEE ALSO
L<check-accelerator-conflicts.pl>, C<xgettext(1)>, C<msgmerge(1)> L<msgaccel-check>, C<xgettext(1)>, C<msgmerge(1)>