mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-13 11:23:09 +03:00
Merge branch '1711_fileop_i18n'
* 1711_fileop_i18n: More usage of gettext context. Minor otimization of panel_operate_generate_prompt(). Ticket #1711: i18n: context and cleanup in file prompt strings
This commit is contained in:
commit
bf8edbabeb
@ -292,16 +292,16 @@ edit_labels (WEdit *edit)
|
||||
{
|
||||
Dlg_head *h = edit->widget.parent;
|
||||
|
||||
edit_my_define (h, 1, _("Help"), cmd_F1, edit);
|
||||
edit_my_define (h, 2, _("Save"), cmd_F2, edit);
|
||||
edit_my_define (h, 3, _("Mark"), cmd_F3, edit);
|
||||
edit_my_define (h, 4, _("Replac"), cmd_F4, edit);
|
||||
edit_my_define (h, 5, _("Copy"), cmd_F5, edit);
|
||||
edit_my_define (h, 6, _("Move"), cmd_F6, edit);
|
||||
edit_my_define (h, 7, _("Search"), cmd_F7, edit);
|
||||
edit_my_define (h, 8, _("Delete"), cmd_F8, edit);
|
||||
edit_my_define (h, 9, _("PullDn"), edit_menu_cmd, edit);
|
||||
edit_my_define (h, 10, _("Quit"), cmd_F10, edit);
|
||||
edit_my_define (h, 1, Q_("ButtonBar|Help"), cmd_F1, edit);
|
||||
edit_my_define (h, 2, Q_("ButtonBar|Save"), cmd_F2, edit);
|
||||
edit_my_define (h, 3, Q_("ButtonBar|Mark"), cmd_F3, edit);
|
||||
edit_my_define (h, 4, Q_("ButtonBar|Replac"), cmd_F4, edit);
|
||||
edit_my_define (h, 5, Q_("ButtonBar|Copy"), cmd_F5, edit);
|
||||
edit_my_define (h, 6, Q_("ButtonBar|Move"), cmd_F6, edit);
|
||||
edit_my_define (h, 7, Q_("ButtonBar|Search"), cmd_F7, edit);
|
||||
edit_my_define (h, 8, Q_("ButtonBar|Delete"), cmd_F8, edit);
|
||||
edit_my_define (h, 9, Q_("ButtonBar|PullDn"), edit_menu_cmd, edit);
|
||||
edit_my_define (h, 10, Q_("ButtonBar|Quit"), cmd_F10, edit);
|
||||
|
||||
buttonbar_redraw (h);
|
||||
}
|
||||
|
70
src/file.c
70
src/file.c
@ -123,12 +123,13 @@ static struct link *erase_list;
|
||||
* Both lists don't use the linkcount and name structure members of struct
|
||||
* link.
|
||||
*/
|
||||
static struct link *dest_dirs = 0;
|
||||
static struct link *dest_dirs = NULL;
|
||||
|
||||
/* TRANSLATORS: no need to translate 'DialogTitle', it's just a context prefix */
|
||||
const char *op_names[3] = {
|
||||
N_(" Copy "),
|
||||
N_(" Move "),
|
||||
N_(" Delete ")
|
||||
N_("DialogTitle|Copy"),
|
||||
N_("DialogTitle|Move"),
|
||||
N_("DialogTitle|Delete")
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
@ -144,10 +145,6 @@ static FileProgressStatus erase_file (FileOpContext *ctx, const char *s,
|
||||
static FileProgressStatus files_error (const char *format, const char *file1,
|
||||
const char *file2);
|
||||
|
||||
|
||||
enum CaseConvs { NO_CONV = 0, UP_CHAR = 1, LOW_CHAR = 2, UP_SECT =
|
||||
4, LOW_SECT = 8 };
|
||||
|
||||
static FileProgressStatus transform_error = FILE_CONT;
|
||||
|
||||
static char *
|
||||
@ -715,7 +712,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
||||
if (dst_status == DEST_SHORT) {
|
||||
/* Remove short file */
|
||||
int result;
|
||||
result = query_dialog (_("Copy"),
|
||||
result = query_dialog (Q_("DialogTitle|Copy"),
|
||||
_("Incomplete file was retrieved. Keep it?"),
|
||||
D_ERROR, 2, _("&Delete"), _("&Keep"));
|
||||
if (!result)
|
||||
@ -1627,15 +1624,15 @@ panel_compute_totals (WPanel *panel, const void *ui,
|
||||
* This array introduced to avoid translation problems. The former (op_names)
|
||||
* is assumed to be nouns, suitable in dialog box titles; this one should
|
||||
* contain whatever is used in prompt itself (i.e. in russian, it's verb).
|
||||
* Notice first symbol - it is to fool gettext and force these strings to
|
||||
* be different for it. First symbol is skipped while building a prompt.
|
||||
* (I don't use spaces around the words, because someday they could be
|
||||
* dropped, when widgets get smarter)
|
||||
*/
|
||||
|
||||
/* TRANSLATORS: no need to translate 'FileOperation', it's just a context prefix */
|
||||
static const char *op_names1[] = {
|
||||
N_("1Copy"),
|
||||
N_("1Move"),
|
||||
N_("1Delete")
|
||||
N_("FileOperation|Copy"),
|
||||
N_("FileOperation|Move"),
|
||||
N_("FileOperation|Delete")
|
||||
};
|
||||
|
||||
/*
|
||||
@ -1662,6 +1659,8 @@ static const char *prompt_parts[] = {
|
||||
N_(" to:")
|
||||
};
|
||||
|
||||
static const char *question_format = N_("%s?");
|
||||
|
||||
/*
|
||||
* Generate user prompt for panel operation.
|
||||
* single_source is the name if the source entry or NULL for multiple
|
||||
@ -1677,37 +1676,47 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
|
||||
int i;
|
||||
char format_string[BUF_MEDIUM];
|
||||
char *dp = format_string;
|
||||
gboolean build_question = FALSE;
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
static int i18n_flag = 0;
|
||||
static gboolean i18n_flag = FALSE;
|
||||
if (!i18n_flag) {
|
||||
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;)
|
||||
op_names1[i] = _(op_names1[i]);
|
||||
op_names1[i] = Q_(op_names1[i]);
|
||||
|
||||
for (i = sizeof (prompt_parts) / sizeof (prompt_parts[0]); i--;)
|
||||
prompt_parts[i] = _(prompt_parts[i]);
|
||||
|
||||
one_format = _(one_format);
|
||||
many_format = _(many_format);
|
||||
i18n_flag = 1;
|
||||
question_format = _(question_format);
|
||||
i18n_flag = TRUE;
|
||||
}
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
sp = single_source ? one_format : many_format;
|
||||
|
||||
while (*sp) {
|
||||
while (*sp != '\0') {
|
||||
switch (*sp) {
|
||||
case '%':
|
||||
cp = NULL;
|
||||
switch (sp[1]) {
|
||||
case 'o':
|
||||
cp = op_names1[operation] + 1;
|
||||
cp = op_names1[operation];
|
||||
break;
|
||||
case 'm':
|
||||
cp = operation == OP_DELETE ? "?" : prompt_parts[5];
|
||||
if (operation == OP_DELETE) {
|
||||
cp = "";
|
||||
build_question = TRUE;
|
||||
} else
|
||||
cp = prompt_parts[5];
|
||||
break;
|
||||
case 'e':
|
||||
cp = operation == OP_DELETE ? "?" : prompt_parts[6];
|
||||
if (operation == OP_DELETE) {
|
||||
cp = "";
|
||||
build_question = TRUE;
|
||||
} else
|
||||
cp = prompt_parts[6];
|
||||
break;
|
||||
case 'f':
|
||||
if (single_source) {
|
||||
@ -1722,9 +1731,9 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
|
||||
default:
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
if (cp) {
|
||||
if (cp != NULL) {
|
||||
sp += 2;
|
||||
while (*cp)
|
||||
while (*cp != '\0')
|
||||
*dp++ = *cp++;
|
||||
}
|
||||
break;
|
||||
@ -1734,6 +1743,14 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
|
||||
}
|
||||
*dp = '\0';
|
||||
|
||||
if (build_question) {
|
||||
char tmp[BUF_MEDIUM];
|
||||
|
||||
memmove (tmp, format_string, sizeof (tmp));
|
||||
g_snprintf (format_string, sizeof (format_string),
|
||||
question_format, tmp);
|
||||
}
|
||||
|
||||
return g_strdup (format_string);
|
||||
}
|
||||
|
||||
@ -1837,8 +1854,9 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
format = panel_operate_generate_prompt (panel, operation,
|
||||
source != NULL, &src_stat);
|
||||
|
||||
dest = file_mask_dialog (ctx, operation, source != NULL,
|
||||
format, source != NULL ? source : &panel->marked,
|
||||
dest = file_mask_dialog (ctx, operation, source != NULL, format,
|
||||
source != NULL ? (void *) source
|
||||
: (void *) &panel->marked,
|
||||
dest_dir_, &do_bg);
|
||||
|
||||
g_free (format);
|
||||
@ -1871,7 +1889,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
if (safe_delete)
|
||||
query_set_sel (1);
|
||||
|
||||
i = query_dialog (_(op_names[operation]), fmd_buf, D_ERROR, 2,
|
||||
i = query_dialog (Q_(op_names[operation]), fmd_buf, D_ERROR, 2,
|
||||
_("&Yes"), _("&No"));
|
||||
|
||||
if (i != 0) {
|
||||
|
@ -884,16 +884,16 @@ interactive_display (const char *filename, const char *node)
|
||||
add_widget (whelp, md);
|
||||
add_widget (whelp, help_bar);
|
||||
|
||||
buttonbar_set_label_data (whelp, 1, _("Help"), help_help_cmd, whelp);
|
||||
buttonbar_set_label_data (whelp, 2, _("Index"), help_index_cmd, whelp);
|
||||
buttonbar_set_label_data (whelp, 3, _("Prev"), prev_node_cmd, whelp);
|
||||
buttonbar_set_label_data (whelp, 1, Q_("ButtonBar|Help"), help_help_cmd, whelp);
|
||||
buttonbar_set_label_data (whelp, 2, Q_("ButtonBar|Index"), help_index_cmd, whelp);
|
||||
buttonbar_set_label_data (whelp, 3, Q_("ButtonBar|Prev"), prev_node_cmd, whelp);
|
||||
buttonbar_clear_label (whelp, 4);
|
||||
buttonbar_clear_label (whelp, 5);
|
||||
buttonbar_clear_label (whelp, 6);
|
||||
buttonbar_clear_label (whelp, 7);
|
||||
buttonbar_clear_label (whelp, 8);
|
||||
buttonbar_clear_label (whelp, 9);
|
||||
buttonbar_set_label_data (whelp, 10, _("Quit"), help_quit_cmd, whelp);
|
||||
buttonbar_set_label_data (whelp, 10, Q_("ButtonBar|Quit"), help_quit_cmd, whelp);
|
||||
|
||||
run_dlg (whelp);
|
||||
interactive_display_finish ();
|
||||
|
@ -1101,10 +1101,10 @@ copy_other_tagged (void)
|
||||
static void
|
||||
init_labels (void)
|
||||
{
|
||||
buttonbar_set_label (midnight_dlg, 1, _("Help"), help_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 2, _("Menu"), user_file_menu_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 9, _("PullDn"), menu_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 10, _("Quit"), quit_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 1, Q_("ButtonBar|Help"), help_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 2, Q_("ButtonBar|Menu"), user_file_menu_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 9, Q_("ButtonBar|PullDn"), menu_cmd);
|
||||
buttonbar_set_label (midnight_dlg, 10, Q_("ButtonBar|Quit"), quit_cmd);
|
||||
}
|
||||
|
||||
static int ctl_x_map_enabled = 0;
|
||||
|
16
src/screen.c
16
src/screen.c
@ -2826,14 +2826,14 @@ panel_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
paint_dir (panel);
|
||||
panel->dirty = 0;
|
||||
|
||||
buttonbar_set_label (h, 1, _("Help"), help_cmd);
|
||||
buttonbar_set_label (h, 2, _("Menu"), user_file_menu_cmd);
|
||||
buttonbar_set_label (h, 3, _("View"), view_cmd);
|
||||
buttonbar_set_label (h, 4, _("Edit"), edit_cmd);
|
||||
buttonbar_set_label (h, 5, _("Copy"), copy_cmd);
|
||||
buttonbar_set_label (h, 6, _("RenMov"), ren_cmd);
|
||||
buttonbar_set_label (h, 7, _("Mkdir"), mkdir_cmd);
|
||||
buttonbar_set_label (h, 8, _("Delete"), delete_cmd);
|
||||
buttonbar_set_label (h, 1, Q_("ButtonBar|Help"), help_cmd);
|
||||
buttonbar_set_label (h, 2, Q_("ButtonBar|Menu"), user_file_menu_cmd);
|
||||
buttonbar_set_label (h, 3, Q_("ButtonBar|View"), view_cmd);
|
||||
buttonbar_set_label (h, 4, Q_("ButtonBar|Edit"), edit_cmd);
|
||||
buttonbar_set_label (h, 5, Q_("ButtonBar|Copy"), copy_cmd);
|
||||
buttonbar_set_label (h, 6, Q_("ButtonBar|RenMov"), ren_cmd);
|
||||
buttonbar_set_label (h, 7, Q_("ButtonBar|Mkdir"), mkdir_cmd);
|
||||
buttonbar_set_label (h, 8, Q_("ButtonBar|Delete"), delete_cmd);
|
||||
buttonbar_redraw (h);
|
||||
return MSG_HANDLED;
|
||||
|
||||
|
22
src/tree.c
22
src/tree.c
@ -622,7 +622,7 @@ tree_copy (WTree *tree, const char *default_dest)
|
||||
|
||||
g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
|
||||
str_trunc (tree->selected_ptr->name, 50));
|
||||
dest = input_expand_dialog (_(" Copy "), msg, MC_HISTORY_FM_TREE_COPY, default_dest);
|
||||
dest = input_expand_dialog (Q_("DialogTitle|Copy"), msg, MC_HISTORY_FM_TREE_COPY, default_dest);
|
||||
|
||||
if (dest != NULL && *dest != '\0') {
|
||||
ctx = file_op_context_new (OP_COPY);
|
||||
@ -662,7 +662,7 @@ tree_move (WTree *tree, const char *default_dest)
|
||||
|
||||
g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
|
||||
str_trunc (tree->selected_ptr->name, 50));
|
||||
dest = input_expand_dialog (_(" Move "), msg, MC_HISTORY_FM_TREE_MOVE, default_dest);
|
||||
dest = input_expand_dialog (Q_("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest);
|
||||
|
||||
if (dest == NULL || *dest == '\0') {
|
||||
g_free (dest);
|
||||
@ -735,7 +735,7 @@ tree_rmdir_cmd (WTree *tree)
|
||||
g_strdup_printf (_(" Delete %s? "),
|
||||
tree->selected_ptr->name);
|
||||
result =
|
||||
query_dialog (_(" Delete "), buf, D_ERROR, 2, _("&Yes"), _("&No"));
|
||||
query_dialog (Q_("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
|
||||
g_free (buf);
|
||||
if (result != 0)
|
||||
return;
|
||||
@ -764,7 +764,7 @@ static void
|
||||
set_navig_label (WTree *tree)
|
||||
{
|
||||
buttonbar_set_label_data (tree->widget.parent, 4,
|
||||
tree_navigation_flag ? _("Static") : _("Dynamc"),
|
||||
tree_navigation_flag ? Q_("ButtonBar|Static") : Q_("ButtonBar|Dynamc"),
|
||||
tree_toggle_navig, tree);
|
||||
}
|
||||
|
||||
@ -1020,19 +1020,19 @@ tree_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
tree->active = 1;
|
||||
buttonbar_set_label (h, 1, _("Help"), tree_help_cmd);
|
||||
buttonbar_set_label_data (h, 2, _("Rescan"),
|
||||
buttonbar_set_label (h, 1, Q_("ButtonBar|Help"), tree_help_cmd);
|
||||
buttonbar_set_label_data (h, 2, Q_("ButtonBar|Rescan"),
|
||||
tree_rescan_command, tree);
|
||||
buttonbar_set_label_data (h, 3, _("Forget"), tree_forget_cmd, tree);
|
||||
buttonbar_set_label_data (h, 5, _("Copy"), tree_copy_cmd, tree);
|
||||
buttonbar_set_label_data (h, 6, _("RenMov"), tree_move_cmd, tree);
|
||||
buttonbar_set_label_data (h, 3, Q_("ButtonBar|Forget"), tree_forget_cmd, tree);
|
||||
buttonbar_set_label_data (h, 5, Q_("ButtonBar|Copy"), tree_copy_cmd, tree);
|
||||
buttonbar_set_label_data (h, 6, Q_("ButtonBar|RenMov"), tree_move_cmd, tree);
|
||||
#if 0
|
||||
/* FIXME: mkdir is currently defunct */
|
||||
buttonbar_set_label_data (h, 7, _("Mkdir"), tree_mkdir_cmd, tree);
|
||||
buttonbar_set_label_data (h, 7, Q_("ButtonBar|Mkdir"), tree_mkdir_cmd, tree);
|
||||
#else
|
||||
buttonbar_clear_label (h, 7);
|
||||
#endif
|
||||
buttonbar_set_label_data (h, 8, _("Rmdir"), tree_rmdir_command, tree);
|
||||
buttonbar_set_label_data (h, 8, Q_("ButtonBar|Rmdir"), tree_rmdir_command, tree);
|
||||
set_navig_label (tree);
|
||||
buttonbar_redraw (h);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user