mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Here is a framework that detects cases where a PO file assigns
the same accelerator key to multiple buttons in a dialog box or to multiple items in a menu. ELinks already has some support for this but it requires the translator to run ELinks and manually scan through all menus and dialogs. The attached changes make it possible to quickly detect and list any conflicts, including ones that can only occur on operating systems or configurations that the translator is not currently using. The changes have no immediate effect on the elinks executable or the MO files. PO files become larger, however. The scheme works like this: - Like before, accelerator keys in translatable strings are tagged with the tilde (~) character. - Whenever a C source file defines an accelerator key, it must assign one or more named "contexts" to it. The translations in the PO files inherit these contexts. If multiple strings use the same accelerator (case insensitive) in the same context, that's a conflict and can be detected automatically. - The contexts are defined with "gettext_accelerator_context" comments in source files. These comments delimit regions where all translatable strings containing tildes are given the same contexts. There must be one special comment at the top of the region; it lists the contexts assigned to that region. The region automatically ends at the end of the function (found with regexp /^\}/), but it can also be closed explicitly with another special comment. The comments are formatted like this: /* [gettext_accelerator_context(foo, bar, baz)] begins a region that uses the contexts "foo", "bar", and "baz". The comma is the delimiter; whitespace is optional. [gettext_accelerator_context()] ends the region. */ The scripts don't currently check whether this syntax occurs inside or outside comments. - The names of contexts consist of C identifiers delimited with periods. I typically used the name of a function that sets up a dialog, or the name of an array where the items of a menu are listed. There is a special feature for static functions: if the name begins with a period, then the period will be replaced with the name of the source file and a colon. - If a menu is programmatically generated from multiple parts, of which some are never used together, so that it is safe to use the same accelerators in them, then it is necessary to define multiple contexts for the same menu. link_menu() in src/viewer/text/link.c is the most complex example of this. - During make update-po: - A Perl script (po/gather-accelerator-contexts.pl) reads po/elinks.pot, scans the source files listed in it for "gettext_accelerator_context" comments, and rewrites po/elinks.pot with "accelerator_context" comments that indicate the contexts of each msgid: the union of all contexts of all of its uses in the source files. It also removes any "gettext_accelerator_context" comments that xgettext --add-comments has copied to elinks.pot. - If po/gather-accelerator-contexts.pl does not find any contexts for some use of an msgid that seems to contain an accelerator (because it contains a tilde), it warns. If the tilde refers to e.g. "~/.elinks" and does not actually mark an accelerator, the warning can be silenced by specifying the special context "IGNORE", which the script otherwise ignores. - msgmerge copies the "accelerator_context" comments from po/elinks.pot to po/*.po. Translators do not edit those comments. - During make check-po: - Another Perl script (po/check-accelerator-contexts.pl) reads po/*.po and keeps track of which accelerators have been bound in each context. It warns about any conflicts it finds. This script does not access the C source files; thus it does not matter if the line numbers in "#:" lines are out of date. This implementation is not perfect and I am not proposing to add it to the main source tree at this time. Specifically: - It introduces compile-time dependencies on Perl and Locale::PO. There should be a configure-time or compile-time check so that the new features are skipped if the prerequisites are missing. - When the scripts include msgstr strings in warnings, they should transcode them from the charset of the PO file to the one specified by the user's locale. - It is not adequately documented (well, except perhaps here). - po/check-accelerator-contexts.pl reports the same conflict multiple times if it occurs in multiple contexts. - The warning messages should include line numbers, so that users of Emacs could conveniently edit the conflicting part of the PO file. This is not feasible with the current version of Locale::PO. - Locale::PO does not understand #~ lines and spews warnings about them. There is an ugly hack to hide these warnings. - Jonas Fonseca suggested the script could propose accelerators that are still available. This has not been implemented. There are three files attached: - po/gather-accelerator-contexts.pl: Augments elinks.pot with context information. - po/check-accelerator-contexts.pl: Checks conflicts. - accelerator-contexts.diff: Makes po/Makefile run the scripts, and adds special comments to source files.
This commit is contained in:
parent
f25f944123
commit
4c2831677a
@ -49,13 +49,14 @@ $(srcdir)/$(POTFILES_ABS_LIST):
|
||||
find src/ -type f -name '*.[ch]' -o -name options.inc -o -name 'actions-*.inc' | sort ) \
|
||||
> $(srcdir)/$(POTFILES_ABS_LIST)
|
||||
|
||||
$(srcdir)/$(PACKAGE).pot: $(srcdir)/$(POTFILES_ABS_LIST)
|
||||
$(srcdir)/$(PACKAGE).pot: $(srcdir)/$(POTFILES_ABS_LIST) $(srcdir)/gather-accelerator-contexts.pl
|
||||
$(XGETTEXT) --default-domain=$(PACKAGE) \
|
||||
--directory=$(top_srcdir) \
|
||||
--add-comments --language=C \
|
||||
--keyword=_ --keyword=N_ --keyword=n_:1,2 --keyword=N__ -f $(srcdir)/$(POTFILES_ABS_LIST) \
|
||||
&& test -f $(PACKAGE).po \
|
||||
&& mv -f $(PACKAGE).po $(srcdir)/$(PACKAGE).pot
|
||||
&& $(srcdir)/gather-accelerator-contexts.pl $(top_srcdir) $(PACKAGE).po \
|
||||
&& mv -f $(PACKAGE).po $(srcdir)/$(PACKAGE).pot
|
||||
|
||||
|
||||
### Updating po and gmo files
|
||||
@ -89,6 +90,7 @@ check-po:
|
||||
@$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \
|
||||
echo -n "$(lang): "; \
|
||||
$(GMSGFMT) --check --check-accelerators=~ --verbose --statistics -o /dev/null $(srcdir)/$(lang).po; \
|
||||
$(srcdir)/check-accelerator-contexts.pl $(srcdir)/$(lang).po \
|
||||
)
|
||||
|
||||
### Installation and distribution
|
||||
|
36
po/check-accelerator-contexts.pl
Normal file
36
po/check-accelerator-contexts.pl
Normal file
@ -0,0 +1,36 @@
|
||||
#! /usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Locale::PO qw();
|
||||
|
||||
my %contexts;
|
||||
my($pofile) = @ARGV;
|
||||
my $pos = do {
|
||||
# Locale::PO 0.16 doesn't understand "#~" obsolete lines and spews warnings.
|
||||
local $SIG{__WARN__} = sub {};
|
||||
Locale::PO->load_file_asarray($pofile) or die "$pofile: $!";
|
||||
};
|
||||
foreach my $po (@$pos) {
|
||||
next if $po->fuzzy();
|
||||
my $msgstr = $po->msgstr()
|
||||
or next;
|
||||
my($accelerator) = ($msgstr =~ /~(.)/)
|
||||
or next;
|
||||
$accelerator = uc($accelerator);
|
||||
my $automatic = $po->automatic()
|
||||
or next;
|
||||
my($contexts) = ($automatic =~ /^accelerator_context\(([^\)]*)\)/)
|
||||
or next;
|
||||
foreach my $context (split(/\s*,\s*/, $contexts)) {
|
||||
my $prev = $contexts{$context}{$accelerator};
|
||||
if (defined($prev)) {
|
||||
warn "$pofile: Accelerator conflict for \"$accelerator\" in \"$context\":\n";
|
||||
warn "$pofile: 1st msgid " . $prev->msgid() . "\n";
|
||||
warn "$pofile: 1st msgstr " . $prev->msgstr() . "\n";
|
||||
warn "$pofile: 2nd msgid " . $po->msgid() . "\n";
|
||||
warn "$pofile: 2nd msgstr " . $po->msgstr() . "\n";
|
||||
} else {
|
||||
$contexts{$context}{$accelerator} = $po;
|
||||
}
|
||||
}
|
||||
}
|
106
po/gather-accelerator-contexts.pl
Normal file
106
po/gather-accelerator-contexts.pl
Normal file
@ -0,0 +1,106 @@
|
||||
#! /usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Locale::PO qw();
|
||||
|
||||
{
|
||||
package Contextline;
|
||||
use fields qw(lineno contexts);
|
||||
sub new {
|
||||
my($self, $lineno, $contexts) = @_;
|
||||
$self = fields::new($self) unless ref $self;
|
||||
$self->{lineno} = $lineno;
|
||||
$self->{contexts} = $contexts;
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
|
||||
# Each key is a file name.
|
||||
# Each value is a reference to an array of references to Contextline
|
||||
# pseudo-hashes. The array is in ascending order by {lineno}.
|
||||
my %Srcfiles;
|
||||
|
||||
# Scan the $srcfile for gettext_accelerator_context directives,
|
||||
# cache the result in %Srcfiles, and return it in that format.
|
||||
sub contextlines ($$)
|
||||
{
|
||||
my($top_srcdir, $srcfile) = @_;
|
||||
return $Srcfiles{$srcfile} if exists($Srcfiles{$srcfile});
|
||||
|
||||
local $_;
|
||||
my @contextlines = ();
|
||||
my @prevctxs;
|
||||
open my $srcfd, "<", "$top_srcdir/$srcfile" or die "$top_srcdir/$srcfile: $!";
|
||||
while (<$srcfd>) {
|
||||
chomp;
|
||||
if (/^\}/ && @prevctxs) {
|
||||
push @contextlines, Contextline->new($., [@prevctxs = ()]);
|
||||
}
|
||||
if (my($contexts) = /\[gettext_accelerator_context\(([^()]*)\)\]/) {
|
||||
my @contexts = grep { $_ ne "" } split(/\s*,\s*/, $contexts);
|
||||
foreach (@contexts) { s/^\./${srcfile}:/ }
|
||||
warn "$srcfile:$.: Previous context not closed\n"
|
||||
if @prevctxs && @contexts;
|
||||
warn "$srcfile:$.: Context already closed\n"
|
||||
if !@prevctxs && !@contexts;
|
||||
push @contextlines, Contextline->new($., [@prevctxs = @contexts]);
|
||||
} elsif (/gettext_accelerator_context/) {
|
||||
warn "$srcfile:$.: Suspicious non-directive: $_\n";
|
||||
}
|
||||
}
|
||||
warn "$srcfile:$.: Last context not closed\n" if @prevctxs;
|
||||
|
||||
return $Srcfiles{$srcfile} = \@contextlines;
|
||||
}
|
||||
|
||||
sub contexts ($$$)
|
||||
{
|
||||
my($top_srcdir, $srcfile, $lineno) = @_;
|
||||
# Could use a binary search here.
|
||||
my $contextlines = contextlines($top_srcdir, $srcfile);
|
||||
my @contexts = ();
|
||||
foreach my Contextline $contextline (@{$contextlines}) {
|
||||
return @contexts if $contextline->{lineno} > $lineno;
|
||||
@contexts = @{$contextline->{contexts}};
|
||||
}
|
||||
return ();
|
||||
}
|
||||
|
||||
sub format_contexts (@)
|
||||
{
|
||||
if (@_) {
|
||||
return "#. accelerator_context(" . join(", ", @_) . ")\n";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
my($top_srcdir, $pofile) = @ARGV;
|
||||
my $pos = Locale::PO->load_file_asarray($pofile) or die "$pofile: $!";
|
||||
foreach my $po (@$pos) {
|
||||
my $automatic = $po->automatic();
|
||||
$automatic =~ s/^\[gettext_accelerator_context\(.*(?:\n|\z)//mg
|
||||
if defined($automatic);
|
||||
|
||||
if ($po->msgid() =~ /\~/) {
|
||||
my @po_contexts = ();
|
||||
foreach my $ref (split(' ', $po->reference())) {
|
||||
my @parts = split(/\:/, $ref);
|
||||
warn "weird reference: $ref\n", next unless @parts == 2;
|
||||
my @ref_contexts = contexts($top_srcdir, $parts[0], $parts[1]);
|
||||
if (@ref_contexts) {
|
||||
push @po_contexts, grep { $_ ne "IGNORE" } @ref_contexts;
|
||||
} else {
|
||||
warn "$ref: No accelerator context for msgid " . $po->msgid() . "\n";
|
||||
}
|
||||
}
|
||||
if (@po_contexts) {
|
||||
# sort and uniquify
|
||||
@po_contexts = sort keys %{{map { $_ => 1 } @po_contexts}};
|
||||
$automatic .= "\n" if defined($automatic) and $automatic ne "";
|
||||
$automatic .= "accelerator_context(" . join(", ", @po_contexts) . ")";
|
||||
}
|
||||
}
|
||||
$po->automatic($automatic);
|
||||
}
|
||||
Locale::PO->save_file_fromarray($pofile, $pos) or die "$pofile: $!";
|
@ -405,6 +405,7 @@ done_listbox_context(void *context_)
|
||||
widget_handler_status_T
|
||||
push_hierbox_info_button(struct dialog_data *dlg_data, struct widget_data *button)
|
||||
{
|
||||
/* [gettext_accelerator_context(push_hierbox_info_button)] */
|
||||
struct listbox_data *box = get_dlg_listbox_data(dlg_data);
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
struct listbox_context *context;
|
||||
@ -692,6 +693,7 @@ widget_handler_status_T
|
||||
push_hierbox_delete_button(struct dialog_data *dlg_data,
|
||||
struct widget_data *button)
|
||||
{
|
||||
/* [gettext_accelerator_context(push_hierbox_delete_button)] */
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
struct listbox_data *box = get_dlg_listbox_data(dlg_data);
|
||||
struct listbox_context *context;
|
||||
@ -816,6 +818,7 @@ widget_handler_status_T
|
||||
push_hierbox_clear_button(struct dialog_data *dlg_data,
|
||||
struct widget_data *button)
|
||||
{
|
||||
/* [gettext_accelerator_context(push_hierbox_clear_button)] */
|
||||
struct listbox_data *box = get_dlg_listbox_data(dlg_data);
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
struct listbox_context *context;
|
||||
|
@ -250,7 +250,8 @@ input_dialog(struct terminal *term, struct memory_list *ml,
|
||||
widget_handler_T *check,
|
||||
void (*fn)(void *, unsigned char *),
|
||||
void (*cancelfn)(void *))
|
||||
{
|
||||
{
|
||||
/* [gettext_accelerator_context(input_dialog)] */
|
||||
input_field(term, ml, 1, title, text, N_("~OK"), N_("~Cancel"),
|
||||
data, history, l,
|
||||
def, min, max,
|
||||
|
@ -160,6 +160,7 @@ refreshed_msg_box(struct terminal *term, enum msgbox_flags flags,
|
||||
unsigned char *(get_info)(struct terminal *, void *),
|
||||
void *data)
|
||||
{
|
||||
/* [gettext_accelerator_context(refreshed_msg_box)] */
|
||||
struct dialog_data *dlg_data;
|
||||
unsigned char *info = get_info(term, data);
|
||||
|
||||
@ -185,6 +186,7 @@ info_box(struct terminal *term, enum msgbox_flags flags,
|
||||
unsigned char *title, enum format_align align,
|
||||
unsigned char *text)
|
||||
{
|
||||
/* [gettext_accelerator_context(info_box)] */
|
||||
return msg_box(term, NULL, flags, title, align, text,
|
||||
NULL, 1, N_("~OK"), NULL, B_ENTER | B_ESC);
|
||||
}
|
||||
|
@ -459,6 +459,7 @@ push_move_button(struct dialog_data *dlg_data,
|
||||
/**** MANAGEMENT *****************************************************/
|
||||
|
||||
static struct hierbox_browser_button bookmark_buttons[] = {
|
||||
/* [gettext_accelerator_context(.bookmark_buttons)] */
|
||||
{ N_("~Goto"), push_hierbox_goto_button, 1 },
|
||||
{ N_("~Edit"), push_edit_button, 0 },
|
||||
{ N_("~Delete"), push_hierbox_delete_button, 0 },
|
||||
|
1
src/cache/dialogs.c
vendored
1
src/cache/dialogs.c
vendored
@ -225,6 +225,7 @@ static struct listbox_ops cache_entry_listbox_ops = {
|
||||
};
|
||||
|
||||
static struct hierbox_browser_button cache_buttons[] = {
|
||||
/* [gettext_accelerator_context(.cache_buttons)] */
|
||||
{ N_("~Info"), push_hierbox_info_button, 1 },
|
||||
{ N_("~Goto"), push_hierbox_goto_button, 1 },
|
||||
{ N_("~Delete"), push_hierbox_delete_button, 1 },
|
||||
|
@ -643,6 +643,7 @@ printconfigdump_cmd(struct option *option, unsigned char ***argv, int *argc)
|
||||
/* Keep options in alphabetical order. */
|
||||
|
||||
struct option_info cmdline_options_info[] = {
|
||||
/* [gettext_accelerator_context(IGNORE)] */
|
||||
INIT_OPT_BOOL("", N_("Restrict to anonymous mode"),
|
||||
"anonymous", 0, 0,
|
||||
N_("Restricts ELinks so it can run on an anonymous account.\n"
|
||||
|
@ -43,6 +43,7 @@ void
|
||||
write_config_dialog(struct terminal *term, unsigned char *config_file,
|
||||
int secsave_error, int stdio_error)
|
||||
{
|
||||
/* [gettext_accelerator_context(write_config_dialog)] */
|
||||
unsigned char *errmsg = NULL;
|
||||
unsigned char *strerr;
|
||||
|
||||
@ -327,6 +328,7 @@ static void
|
||||
build_edit_dialog(struct terminal *term, struct session *ses,
|
||||
struct option *option)
|
||||
{
|
||||
/* [gettext_accelerator_context(.build_edit_dialog)] */
|
||||
#define EDIT_WIDGETS_COUNT 5
|
||||
struct dialog *dlg;
|
||||
unsigned char *value, *name, *desc, *range;
|
||||
@ -523,6 +525,7 @@ push_save_button(struct dialog_data *dlg_data,
|
||||
|
||||
|
||||
static struct hierbox_browser_button option_buttons[] = {
|
||||
/* [gettext_accelerator_context(.option_buttons)] */
|
||||
{ N_("~Info"), push_hierbox_info_button, 1 },
|
||||
{ N_("~Edit"), push_edit_button, 0 },
|
||||
{ N_("~Add"), push_add_button, 0 },
|
||||
@ -809,6 +812,7 @@ really_really_add_keybinding(void *data)
|
||||
static void
|
||||
really_add_keybinding(void *data, unsigned char *keystroke)
|
||||
{
|
||||
/* [gettext_accelerator_context(.really_add_keybinding.yn)] */
|
||||
struct kbdbind_add_hop *hop = data;
|
||||
action_id_T action_id;
|
||||
|
||||
@ -936,6 +940,7 @@ push_kbdbind_save_button(struct dialog_data *dlg_data,
|
||||
static INIT_LIST_HEAD(keybinding_dialog_list);
|
||||
|
||||
static struct hierbox_browser_button keybinding_buttons[] = {
|
||||
/* [gettext_accelerator_context(.keybinding_buttons)] */
|
||||
{ N_("~Add"), push_kbdbind_add_button, 0 },
|
||||
{ N_("~Delete"), push_hierbox_delete_button, 0 },
|
||||
{ N_("~Toggle display"), push_kbdbind_toggle_display_button, 1 },
|
||||
|
@ -15,6 +15,7 @@
|
||||
* 5. Love thy option system! :) */
|
||||
|
||||
static struct option_info config_options_info[] = {
|
||||
/* [gettext_accelerator_context(IGNORE)] */
|
||||
INIT_OPT_TREE("", N_("Configuration system"),
|
||||
"config", 0,
|
||||
N_("Configuration handling options.")),
|
||||
|
@ -54,6 +54,7 @@ add_cookie_info_to_string(struct string *string, struct cookie *cookie,
|
||||
void
|
||||
accept_cookie_dialog(struct session *ses, void *data)
|
||||
{
|
||||
/* [gettext_accelerator_context(accept_cookie_dialog)] */
|
||||
struct cookie *cookie = cookie_queries.next;
|
||||
struct string string;
|
||||
|
||||
@ -310,6 +311,7 @@ static void
|
||||
build_edit_dialog(struct terminal *term, struct cookie *cookie)
|
||||
{
|
||||
#define EDIT_WIDGETS_COUNT 8
|
||||
/* [gettext_accelerator_context(.build_edit_dialog)] */
|
||||
struct dialog *dlg;
|
||||
unsigned char *name, *value, *domain, *expires, *secure;
|
||||
unsigned char *dlg_server;
|
||||
@ -416,6 +418,7 @@ push_save_button(struct dialog_data *dlg_data, struct widget_data *button)
|
||||
}
|
||||
|
||||
static struct hierbox_browser_button cookie_buttons[] = {
|
||||
/* [gettext_accelerator_context(.cookie_buttons)] */
|
||||
{ N_("~Info"), push_hierbox_info_button, 1 },
|
||||
{ N_("~Add"), push_add_button, 1 },
|
||||
{ N_("~Edit"), push_edit_button, 1 },
|
||||
|
@ -218,6 +218,7 @@ void
|
||||
display_download(struct terminal *term, struct file_download *file_download,
|
||||
struct session *ses)
|
||||
{
|
||||
/* [gettext_accelerator_context(display_download)] */
|
||||
struct dialog *dlg;
|
||||
|
||||
if (!is_in_downloads_list(file_download))
|
||||
@ -475,6 +476,7 @@ push_info_button(struct dialog_data *dlg_data, struct widget_data *button)
|
||||
* - Toggle notify button
|
||||
*/
|
||||
static struct hierbox_browser_button download_buttons[] = {
|
||||
/* [gettext_accelerator_context(.download_buttons)] */
|
||||
{ N_("~Info"), push_info_button },
|
||||
{ N_("~Abort"), push_hierbox_delete_button },
|
||||
#if 0
|
||||
|
@ -48,6 +48,7 @@ do_edit_dialog(struct terminal *term, int intl, unsigned char *title,
|
||||
void *done_data,
|
||||
enum edit_dialog_type dialog_type)
|
||||
{
|
||||
/* [gettext_accelerator_context(do_edit_dialog)] */
|
||||
unsigned char *name, *url;
|
||||
struct dialog *dlg;
|
||||
|
||||
|
@ -58,6 +58,7 @@ push_toggle_keys_display_button(void *data)
|
||||
void
|
||||
menu_keys(struct terminal *term, void *d_, void *xxx)
|
||||
{
|
||||
/* [gettext_accelerator_context(menu_keys)] */
|
||||
int d = (long) d_;
|
||||
|
||||
/* We scale by main mapping because it has the most actions */
|
||||
|
@ -115,6 +115,7 @@ dont_exit_prog(struct session *ses)
|
||||
void
|
||||
query_exit(struct session *ses)
|
||||
{
|
||||
/* [gettext_accelerator_context(query_exit)] */
|
||||
ses->exit_query = 1;
|
||||
msg_box(ses->tab->term, NULL, 0,
|
||||
N_("Exit ELinks"), ALIGN_CENTER,
|
||||
@ -215,6 +216,7 @@ unhistory_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
void
|
||||
tab_menu(struct session *ses, int x, int y, int place_above_cursor)
|
||||
{
|
||||
/* [gettext_accelerator_context(tab_menu.uri_frame, tab_menu.uri_link, tab_menu.uri_tab)] */
|
||||
struct menu_item *menu;
|
||||
int tabs;
|
||||
#ifdef CONFIG_BOOKMARKS
|
||||
@ -297,6 +299,7 @@ do_submenu(struct terminal *term, void *menu_, void *ses_)
|
||||
|
||||
|
||||
static struct menu_item file_menu11[] = {
|
||||
/* [gettext_accelerator_context(.file_menu)] */
|
||||
INIT_MENU_ACTION(N_("Open new ~tab"), ACT_MAIN_OPEN_NEW_TAB),
|
||||
INIT_MENU_ACTION(N_("Open new tab in backgroun~d"), ACT_MAIN_OPEN_NEW_TAB_IN_BACKGROUND),
|
||||
INIT_MENU_ACTION(N_("~Go to URL"), ACT_MAIN_GOTO_URL),
|
||||
@ -307,6 +310,7 @@ static struct menu_item file_menu11[] = {
|
||||
};
|
||||
|
||||
static struct menu_item file_menu21[] = {
|
||||
/* [gettext_accelerator_context(.file_menu)] */
|
||||
BAR_MENU_ITEM,
|
||||
INIT_MENU_ACTION(N_("~Save as"), ACT_MAIN_SAVE_AS),
|
||||
INIT_MENU_ACTION(N_("Save UR~L as"), ACT_MAIN_SAVE_URL_AS),
|
||||
@ -317,6 +321,7 @@ static struct menu_item file_menu21[] = {
|
||||
};
|
||||
|
||||
static struct menu_item file_menu22[] = {
|
||||
/* [gettext_accelerator_context(.file_menu)] */
|
||||
BAR_MENU_ITEM,
|
||||
INIT_MENU_ACTION(N_("~Kill background connections"), ACT_MAIN_KILL_BACKGROUNDED_CONNECTIONS),
|
||||
INIT_MENU_ACTION(N_("Flush all ~caches"), ACT_MAIN_CACHE_MINIMIZE),
|
||||
@ -325,6 +330,7 @@ static struct menu_item file_menu22[] = {
|
||||
};
|
||||
|
||||
static struct menu_item file_menu3[] = {
|
||||
/* [gettext_accelerator_context(.file_menu)] */
|
||||
BAR_MENU_ITEM,
|
||||
INIT_MENU_ACTION(N_("E~xit"), ACT_MAIN_QUIT),
|
||||
NULL_MENU_ITEM,
|
||||
@ -333,6 +339,7 @@ static struct menu_item file_menu3[] = {
|
||||
static void
|
||||
do_file_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
{
|
||||
/* [gettext_accelerator_context(.file_menu)] */
|
||||
struct menu_item *file_menu, *e, *f;
|
||||
int anonymous = get_cmd_opt_bool("anonymous");
|
||||
int x, o;
|
||||
@ -394,6 +401,7 @@ do_file_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
}
|
||||
|
||||
static struct menu_item view_menu[] = {
|
||||
/* [gettext_accelerator_context(.view_menu)] */
|
||||
INIT_MENU_ACTION(N_("~Search"), ACT_MAIN_SEARCH),
|
||||
INIT_MENU_ACTION(N_("Search ~backward"), ACT_MAIN_SEARCH_BACK),
|
||||
INIT_MENU_ACTION(N_("Find ~next"), ACT_MAIN_FIND_NEXT),
|
||||
@ -420,6 +428,7 @@ static struct menu_item view_menu[] = {
|
||||
|
||||
|
||||
static struct menu_item help_menu[] = {
|
||||
/* [gettext_accelerator_context(.help_menu)] */
|
||||
INIT_MENU_ITEM(N_("~ELinks homepage"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_HOMEPAGE, 0),
|
||||
INIT_MENU_ITEM(N_("~Documentation"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_DOC_URL, 0),
|
||||
INIT_MENU_ITEM(N_("~Keys"), NULL, ACT_MAIN_NONE, menu_keys, NULL, 0),
|
||||
@ -439,6 +448,7 @@ static struct menu_item help_menu[] = {
|
||||
|
||||
|
||||
static struct menu_item ext_menu[] = {
|
||||
/* [gettext_accelerator_context(.ext_menu)] */
|
||||
INIT_MENU_ITEM(N_("~Add"), NULL, ACT_MAIN_NONE, menu_add_ext, NULL, 0),
|
||||
INIT_MENU_ITEM(N_("~Modify"), NULL, ACT_MAIN_NONE, menu_list_ext, menu_add_ext, SUBMENU),
|
||||
INIT_MENU_ITEM(N_("~Delete"), NULL, ACT_MAIN_NONE, menu_list_ext, menu_del_ext, SUBMENU),
|
||||
@ -446,6 +456,7 @@ static struct menu_item ext_menu[] = {
|
||||
};
|
||||
|
||||
static struct menu_item setup_menu[] = {
|
||||
/* [gettext_accelerator_context(.setup_menu)] */
|
||||
#ifdef CONFIG_NLS
|
||||
INIT_MENU_ITEM(N_("~Language"), NULL, ACT_MAIN_NONE, menu_language_list, NULL, SUBMENU),
|
||||
#endif
|
||||
@ -460,6 +471,7 @@ static struct menu_item setup_menu[] = {
|
||||
};
|
||||
|
||||
static struct menu_item setup_menu_anon[] = {
|
||||
/* [gettext_accelerator_context(.setup_menu)] */
|
||||
INIT_MENU_ITEM(N_("~Language"), NULL, ACT_MAIN_NONE, menu_language_list, NULL, SUBMENU),
|
||||
INIT_MENU_ITEM(N_("C~haracter set"), NULL, ACT_MAIN_NONE, charset_list, NULL, SUBMENU),
|
||||
INIT_MENU_ACTION(N_("~Terminal options"), ACT_MAIN_SHOW_TERM_OPTIONS),
|
||||
@ -467,6 +479,7 @@ static struct menu_item setup_menu_anon[] = {
|
||||
};
|
||||
|
||||
static struct menu_item tools_menu[] = {
|
||||
/* [gettext_accelerator_context(.tools_menu)] */
|
||||
#ifdef CONFIG_GLOBHIST
|
||||
INIT_MENU_ACTION(N_("Global ~history"), ACT_MAIN_HISTORY_MANAGER),
|
||||
#endif
|
||||
@ -497,6 +510,7 @@ do_setup_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
}
|
||||
|
||||
static struct menu_item main_menu[] = {
|
||||
/* [gettext_accelerator_context(.main_menu)] */
|
||||
INIT_MENU_ITEM(N_("~File"), NULL, ACT_MAIN_NONE, do_file_menu, NULL, FREE_LIST | SUBMENU),
|
||||
INIT_MENU_ITEM(N_("~View"), NULL, ACT_MAIN_NONE, do_submenu, view_menu, FREE_LIST | SUBMENU),
|
||||
INIT_MENU_ITEM(N_("~Link"), NULL, ACT_MAIN_NONE, link_menu, NULL, FREE_LIST | SUBMENU),
|
||||
@ -867,19 +881,25 @@ add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type)
|
||||
|
||||
switch (type) {
|
||||
case PASS_URI_FRAME:
|
||||
/* [gettext_accelerator_context(tab_menu.uri_frame)] */
|
||||
action_id = ACT_MAIN_FRAME_EXTERNAL_COMMAND;
|
||||
text = N_("~Pass frame URI to external command");
|
||||
/* [gettext_accelerator_context()] */
|
||||
break;
|
||||
|
||||
case PASS_URI_LINK:
|
||||
/* [gettext_accelerator_context(tab_menu.uri_link)] */
|
||||
action_id = ACT_MAIN_LINK_EXTERNAL_COMMAND;
|
||||
text = N_("Pass link URI to e~xternal command");
|
||||
/* [gettext_accelerator_context()] */
|
||||
break;
|
||||
|
||||
default:
|
||||
case PASS_URI_TAB:
|
||||
/* [gettext_accelerator_context(tab_menu.uri_tab)] */
|
||||
action_id = ACT_MAIN_TAB_EXTERNAL_COMMAND;
|
||||
text = N_("Pass tab URI to e~xternal command");
|
||||
/* [gettext_accelerator_context()] */
|
||||
};
|
||||
|
||||
foreach (option, *tree) {
|
||||
|
@ -135,6 +135,7 @@ push_save_button(struct dialog_data *dlg_data, struct widget_data *button)
|
||||
void
|
||||
terminal_options(struct terminal *term, void *xxx, struct session *ses)
|
||||
{
|
||||
/* [gettext_accelerator_context(terminal_options)] */
|
||||
struct dialog *dlg;
|
||||
union option_value *values;
|
||||
int anonymous = get_cmd_opt_bool("anonymous");
|
||||
@ -267,6 +268,7 @@ push_resize_button(void *data)
|
||||
void
|
||||
resize_terminal_dialog(struct terminal *term)
|
||||
{
|
||||
/* [gettext_accelerator_context(resize_terminal_dialog)] */
|
||||
struct dialog *dlg;
|
||||
int width = int_min(term->width, 999);
|
||||
int height = int_min(term->height, 999);
|
||||
|
@ -205,6 +205,7 @@ push_save_button(struct dialog_data *dlg_data, struct widget_data *button)
|
||||
}
|
||||
|
||||
static struct hierbox_browser_button formhist_buttons[] = {
|
||||
/* [gettext_accelerator_context(.formhist_buttons)] */
|
||||
{ N_("~Login"), push_login_button, 1 },
|
||||
{ N_("~Info"), push_hierbox_info_button, 1 },
|
||||
{ N_("~Delete"), push_hierbox_delete_button, 1 },
|
||||
|
@ -376,6 +376,7 @@ void
|
||||
memorize_form(struct session *ses, struct list_head *submit,
|
||||
struct form *forminfo)
|
||||
{
|
||||
/* [gettext_accelerator_context(memorize_form)] */
|
||||
struct formhist_data *form;
|
||||
struct submitted_value *sv;
|
||||
int save = 0;
|
||||
|
@ -220,6 +220,7 @@ push_bookmark_button(struct dialog_data *dlg_data,
|
||||
/* The global history manager: */
|
||||
|
||||
static struct hierbox_browser_button globhist_buttons[] = {
|
||||
/* [gettext_accelerator_context(.globhist_buttons)] */
|
||||
{ N_("~Goto"), push_hierbox_goto_button, 1 },
|
||||
{ N_("~Info"), push_hierbox_info_button, 1 },
|
||||
#ifdef CONFIG_BOOKMARKS
|
||||
|
@ -50,6 +50,7 @@ really_del_ext(void *fcp)
|
||||
void
|
||||
menu_del_ext(struct terminal *term, void *fcp, void *xxx2)
|
||||
{
|
||||
/* [gettext_accelerator_context(menu_del_ext)] */
|
||||
struct option *opt = NULL;
|
||||
unsigned char *extension = fcp;
|
||||
|
||||
@ -96,6 +97,7 @@ add_mime_extension(void *data)
|
||||
void
|
||||
menu_add_ext(struct terminal *term, void *fcp, void *xxx2)
|
||||
{
|
||||
/* [gettext_accelerator_context(menu_add_ext)] */
|
||||
struct extension *new;
|
||||
struct dialog *dlg;
|
||||
|
||||
|
@ -23,18 +23,26 @@
|
||||
#endif
|
||||
|
||||
const struct open_in_new open_in_new[] = {
|
||||
/* [gettext_accelerator_context(open_in_new.os2, open_in_new.win32, open_in_new.beos)] */
|
||||
{ ENV_XWIN, XTERM_CMD, N_("~Xterm") },
|
||||
{ ENV_TWIN, DEFAULT_TWTERM_CMD, N_("T~wterm") },
|
||||
{ ENV_SCREEN, DEFAULT_SCREEN_CMD, N_("~Screen") },
|
||||
/* [gettext_accelerator_context()] */
|
||||
#ifdef CONFIG_OS2
|
||||
/* [gettext_accelerator_context(open_in_new.os2)] */
|
||||
{ ENV_OS2VIO, DEFAULT_OS2_WINDOW_CMD, N_("~Window") },
|
||||
{ ENV_OS2VIO, DEFAULT_OS2_FULLSCREEN_CMD, N_("~Full screen") },
|
||||
/* [gettext_accelerator_context()] */
|
||||
#endif
|
||||
#ifdef CONFIG_WIN32
|
||||
/* [gettext_accelerator_context(open_in_new.win32)] */
|
||||
{ ENV_WIN32, "", N_("~Window") },
|
||||
/* [gettext_accelerator_context()] */
|
||||
#endif
|
||||
#ifdef CONFIG_BEOS
|
||||
/* [gettext_accelerator_context(open_in_new.beos)] */
|
||||
{ ENV_BE, DEFAULT_BEOS_TERM_CMD, N_("~BeOS terminal") },
|
||||
/* [gettext_accelerator_context()] */
|
||||
#endif
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
@ -70,6 +70,7 @@ auth_cancel(void *data)
|
||||
void
|
||||
do_auth_dialog(struct session *ses, void *data)
|
||||
{
|
||||
/* [gettext_accelerator_context(do_auth_dialog)] */
|
||||
struct dialog *dlg;
|
||||
struct dialog_data *dlg_data;
|
||||
struct terminal *term = ses->tab->term;
|
||||
@ -252,6 +253,7 @@ static struct listbox_ops auth_listbox_ops = {
|
||||
};
|
||||
|
||||
static struct hierbox_browser_button auth_buttons[] = {
|
||||
/* [gettext_accelerator_context(.auth_buttons)] */
|
||||
{ N_("~Goto"), push_hierbox_goto_button, 1 },
|
||||
{ N_("~Info"), push_hierbox_info_button, 1 },
|
||||
{ N_("~Delete"), push_hierbox_delete_button, 1 },
|
||||
|
@ -684,6 +684,7 @@ static void
|
||||
bittorrent_query_callback(void *data, enum connection_state state,
|
||||
struct string *response)
|
||||
{
|
||||
/* [gettext_accelerator_context(.bittorrent_query_callback)] */
|
||||
struct type_query *type_query = data;
|
||||
struct string filename;
|
||||
unsigned char *text;
|
||||
|
@ -198,6 +198,7 @@ get_protocol_handler(enum protocol protocol)
|
||||
static void
|
||||
generic_external_protocol_handler(struct session *ses, struct uri *uri)
|
||||
{
|
||||
/* [gettext_accelerator_context(generic_external_protocol_handler)] */
|
||||
enum connection_state state;
|
||||
|
||||
switch (uri->protocol) {
|
||||
|
@ -341,6 +341,7 @@ dialog_run_lua(void *data_)
|
||||
static int
|
||||
l_edit_bookmark_dialog(LS)
|
||||
{
|
||||
/* [gettext_accelerator_context(.l_edit_bookmark_dialog)] */
|
||||
struct terminal *term = lua_ses->tab->term;
|
||||
struct dialog *dlg;
|
||||
struct lua_dlg_data *data;
|
||||
@ -415,6 +416,7 @@ xdialog_run_lua(void *data_)
|
||||
static int
|
||||
l_xdialog(LS)
|
||||
{
|
||||
/* [gettext_accelerator_context(.l_xdialog)] */
|
||||
struct terminal *term;
|
||||
struct dialog *dlg;
|
||||
struct lua_xdialog_data *data;
|
||||
|
@ -469,6 +469,7 @@ lookup_unique_name(struct terminal *term, unsigned char *ofile, int resume,
|
||||
void (*callback)(struct terminal *, unsigned char *, void *, int),
|
||||
void *data)
|
||||
{
|
||||
/* [gettext_accelerator_context(.lookup_unique_name)] */
|
||||
struct lun_hop *lun_hop;
|
||||
unsigned char *file;
|
||||
int overwrite;
|
||||
@ -989,6 +990,7 @@ tp_open(struct type_query *type_query)
|
||||
static void
|
||||
do_type_query(struct type_query *type_query, unsigned char *ct, struct mime_handler *handler)
|
||||
{
|
||||
/* [gettext_accelerator_context(.do_type_query)] */
|
||||
struct string filename;
|
||||
unsigned char *description;
|
||||
unsigned char *desc_sep;
|
||||
|
@ -742,6 +742,7 @@ dialog_goto_url_open(void *data)
|
||||
static int
|
||||
setup_first_session(struct session *ses, struct uri *uri)
|
||||
{
|
||||
/* [gettext_accelerator_context(setup_first_session)] */
|
||||
struct terminal *term = ses->tab->term;
|
||||
|
||||
if (!*get_opt_str("protocol.http.user_agent")) {
|
||||
|
@ -160,6 +160,7 @@ ses_goto(struct session *ses, struct uri *uri, unsigned char *target_frame,
|
||||
struct location *target_location, enum cache_mode cache_mode,
|
||||
enum task_type task_type, int redir)
|
||||
{
|
||||
/* [gettext_accelerator_context(ses_goto)] */
|
||||
struct task *task;
|
||||
int referrer_incomplete = 0;
|
||||
int malicious_uri = 0;
|
||||
|
@ -172,6 +172,7 @@ really_close_tab(struct session *ses)
|
||||
void
|
||||
close_tab(struct terminal *term, struct session *ses)
|
||||
{
|
||||
/* [gettext_accelerator_context(close_tab)] */
|
||||
int num_tabs = number_of_tabs(term);
|
||||
|
||||
if (num_tabs < 2) {
|
||||
@ -212,6 +213,7 @@ really_close_tabs(struct session *ses)
|
||||
void
|
||||
close_all_tabs_but_current(struct session *ses)
|
||||
{
|
||||
/* [gettext_accelerator_context(close_all_tabs_but_current)] */
|
||||
assert(ses);
|
||||
if_assert_failed return;
|
||||
|
||||
|
@ -1145,9 +1145,12 @@ link_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
|
||||
if (link->where && !link_is_form(link)) {
|
||||
if (link->type == LINK_MAP) {
|
||||
/* [gettext_accelerator_context(link_menu.map)] */
|
||||
add_to_menu(&mi, N_("Display ~usemap"), NULL, ACT_MAIN_LINK_FOLLOW,
|
||||
NULL, NULL, SUBMENU);
|
||||
/* [gettext_accelerator_context()] */
|
||||
} else {
|
||||
/* [gettext_accelerator_context(link_menu.std)] */
|
||||
add_menu_action(&mi, N_("~Follow link"), ACT_MAIN_LINK_FOLLOW);
|
||||
|
||||
add_menu_action(&mi, N_("Follow link and r~eload"), ACT_MAIN_LINK_FOLLOW_RELOAD);
|
||||
@ -1171,6 +1174,7 @@ link_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
#endif
|
||||
add_uri_command_to_menu(&mi, PASS_URI_LINK);
|
||||
}
|
||||
/* [gettext_accelerator_context()] */
|
||||
}
|
||||
}
|
||||
|
||||
@ -1178,10 +1182,13 @@ link_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
if (fc) {
|
||||
switch (fc->type) {
|
||||
case FC_RESET:
|
||||
/* [gettext_accelerator_context(link_menu.reset)] */
|
||||
add_menu_action(&mi, N_("~Reset form"), ACT_MAIN_RESET_FORM);
|
||||
/* [gettext_accelerator_context()] */
|
||||
break;
|
||||
|
||||
case FC_TEXTAREA:
|
||||
/* [gettext_accelerator_context(link_menu.textarea)] */
|
||||
if (!form_field_is_readonly(fc)) {
|
||||
struct string keystroke;
|
||||
|
||||
@ -1195,8 +1202,10 @@ link_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
keystroke.source, ACT_MAIN_NONE,
|
||||
menu_textarea_edit, NULL, FREE_RTEXT);
|
||||
}
|
||||
/* [gettext_accelerator_context()] */
|
||||
/* Fall through */
|
||||
default:
|
||||
/* [gettext_accelerator_context(link_menu.textarea, link_menu.form)] */
|
||||
add_menu_action(&mi, N_("~Submit form"), ACT_MAIN_SUBMIT_FORM);
|
||||
add_menu_action(&mi, N_("Submit form and rel~oad"), ACT_MAIN_SUBMIT_FORM_RELOAD);
|
||||
|
||||
@ -1215,13 +1224,16 @@ link_menu(struct terminal *term, void *xxx, void *ses_)
|
||||
add_menu_action(&mi, N_("Submit form and ~download"), ACT_MAIN_LINK_DOWNLOAD);
|
||||
|
||||
add_menu_action(&mi, N_("~Reset form"), ACT_MAIN_RESET_FORM);
|
||||
/* [gettext_accelerator_context()] */
|
||||
}
|
||||
}
|
||||
|
||||
if (link->where_img) {
|
||||
/* [gettext_accelerator_context(link_menu.map, link_menu.std, link_menu.form)] */
|
||||
add_menu_action(&mi, N_("V~iew image"), ACT_MAIN_VIEW_IMAGE);
|
||||
if (!get_cmd_opt_bool("anonymous"))
|
||||
add_menu_action(&mi, N_("Download ima~ge"), ACT_MAIN_LINK_DOWNLOAD_IMAGE);
|
||||
/* [gettext_accelerator_context()] */
|
||||
}
|
||||
|
||||
/* TODO: Make it possible to trigger any script event hooks associated
|
||||
|
@ -1551,6 +1551,7 @@ search_dlg_do(struct terminal *term, struct memory_list *ml,
|
||||
struct input_history *history,
|
||||
void (*fn)(void *, unsigned char *))
|
||||
{
|
||||
/* [gettext_accelerator_context(.search_dlg_do)] */
|
||||
struct dialog *dlg;
|
||||
unsigned char *field;
|
||||
struct search_dlg_hop *hop;
|
||||
|
Loading…
Reference in New Issue
Block a user