per DB's patch, convert more of nano to use N_() when possible; also add

a few more minor cosmetic fixes of mine


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1883 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-08-05 15:45:09 +00:00
parent 22fac783f5
commit 76f63ff58d
2 changed files with 66 additions and 58 deletions

View File

@ -19,9 +19,12 @@ CVS code -
Benbennick) Benbennick)
- Add new N_() macro to mark strings that aren't translated - Add new N_() macro to mark strings that aren't translated
immediately, and convert nano to use it in cases where the immediately, and convert nano to use it in cases where the
same translated string is stored in a const char* and used translated string is stored in a const char*. Changes
more than once. (David Benbennick) DLR: Do this for the to sc_init_one(), print1opt(), help_init(), rcfile_error(),
toggles list for consistency with the shortcut list. do_credits(), etc. (David Benbennick) DLR: Do this for
toggle_init_one() too.
- Minor tweaks and clarifications to some option descriptions.
(DLR)
- Overhaul the shortcut list and toggle list initialization - Overhaul the shortcut list and toggle list initialization
code for efficiency. Changes to shortcut_init() and code for efficiency. Changes to shortcut_init() and
toggle_init(). (David Benbennick) DLR: Move "Cancel" to just toggle_init(). (David Benbennick) DLR: Move "Cancel" to just

View File

@ -274,17 +274,18 @@ void mouse_init(void)
* help_text should be NULL initially. */ * help_text should be NULL initially. */
void help_init(void) void help_init(void)
{ {
size_t allocsize = 1; /* space needed for help_text */ size_t allocsize = 1; /* Space needed for help_text. */
char *ptr = NULL; const char *htx; /* Untranslated help message. */
char *ptr;
const shortcut *s; const shortcut *s;
#ifndef NANO_SMALL #ifndef NANO_SMALL
const toggle *t; const toggle *t;
#endif #endif
/* First set up the initial help text for the current function */ /* First, set up the initial help text for the current function. */
if (currshortcut == whereis_list || currshortcut == replace_list if (currshortcut == whereis_list || currshortcut == replace_list
|| currshortcut == replace_list_2) || currshortcut == replace_list_2)
ptr = _("Search Command Help Text\n\n " htx = N_("Search Command Help Text\n\n "
"Enter the words or characters you would like to search " "Enter the words or characters you would like to search "
"for, then hit enter. If there is a match for the text you " "for, then hit enter. If there is a match for the text you "
"entered, the screen will be updated to the location of the " "entered, the screen will be updated to the location of the "
@ -294,14 +295,14 @@ void help_init(void)
"will perform the previous search.\n\n The following function " "will perform the previous search.\n\n The following function "
"keys are available in Search mode:\n\n"); "keys are available in Search mode:\n\n");
else if (currshortcut == goto_list) else if (currshortcut == goto_list)
ptr = _("Go To Line Help Text\n\n " htx = N_("Go To Line Help Text\n\n "
"Enter the line number that you wish to go to and hit " "Enter the line number that you wish to go to and hit "
"Enter. If there are fewer lines of text than the " "Enter. If there are fewer lines of text than the "
"number you entered, you will be brought to the last line " "number you entered, you will be brought to the last line "
"of the file.\n\n The following function keys are " "of the file.\n\n The following function keys are "
"available in Go To Line mode:\n\n"); "available in Go To Line mode:\n\n");
else if (currshortcut == insertfile_list) else if (currshortcut == insertfile_list)
ptr = _("Insert File Help Text\n\n " htx = N_("Insert File Help Text\n\n "
"Type in the name of a file to be inserted into the current " "Type in the name of a file to be inserted into the current "
"file buffer at the current cursor location.\n\n " "file buffer at the current cursor location.\n\n "
"If you have compiled nano with multiple file buffer " "If you have compiled nano with multiple file buffer "
@ -315,7 +316,7 @@ void help_init(void)
"Enter.\n\n The following function keys are " "Enter.\n\n The following function keys are "
"available in Insert File mode:\n\n"); "available in Insert File mode:\n\n");
else if (currshortcut == writefile_list) else if (currshortcut == writefile_list)
ptr = _("Write File Help Text\n\n " htx = N_("Write File Help Text\n\n "
"Type the name that you wish to save the current file " "Type the name that you wish to save the current file "
"as and hit Enter to save the file.\n\n If you have " "as and hit Enter to save the file.\n\n If you have "
"selected text with Ctrl-^, you will be prompted to " "selected text with Ctrl-^, you will be prompted to "
@ -326,7 +327,7 @@ void help_init(void)
"are available in Write File mode:\n\n"); "are available in Write File mode:\n\n");
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
else if (currshortcut == browser_list) else if (currshortcut == browser_list)
ptr = _("File Browser Help Text\n\n " htx = N_("File Browser Help Text\n\n "
"The file browser is used to visually browse the " "The file browser is used to visually browse the "
"directory structure to select a file for reading " "directory structure to select a file for reading "
"or writing. You may use the arrow keys or Page Up/" "or writing. You may use the arrow keys or Page Up/"
@ -337,7 +338,7 @@ void help_init(void)
"following function keys are available in the file " "following function keys are available in the file "
"browser:\n\n"); "browser:\n\n");
else if (currshortcut == gotodir_list) else if (currshortcut == gotodir_list)
ptr = _("Browser Go To Directory Help Text\n\n " htx = N_("Browser Go To Directory Help Text\n\n "
"Enter the name of the directory you would like to " "Enter the name of the directory you would like to "
"browse to.\n\n If tab completion has not been disabled, " "browse to.\n\n If tab completion has not been disabled, "
"you can use the TAB key to (attempt to) automatically " "you can use the TAB key to (attempt to) automatically "
@ -346,7 +347,7 @@ void help_init(void)
#endif #endif
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
else if (currshortcut == spell_list) else if (currshortcut == spell_list)
ptr = _("Spell Check Help Text\n\n " htx = N_("Spell Check Help Text\n\n "
"The spell checker checks the spelling of all text " "The spell checker checks the spelling of all text "
"in the current file. When an unknown word is " "in the current file. When an unknown word is "
"encountered, it is highlighted and a replacement can " "encountered, it is highlighted and a replacement can "
@ -357,14 +358,15 @@ void help_init(void)
#endif #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
else if (currshortcut == extcmd_list) else if (currshortcut == extcmd_list)
ptr = _("External Command Help Text\n\n " htx = N_("External Command Help Text\n\n "
"This menu allows you to insert the output of a command " "This menu allows you to insert the output of a command "
"run by the shell into the current buffer (or a new " "run by the shell into the current buffer (or a new "
"buffer in multibuffer mode).\n\n The following keys are " "buffer in multibuffer mode).\n\n The following keys are "
"available in this mode:\n\n"); "available in this mode:\n\n");
#endif #endif
else /* Default to the main help list */ else
ptr = _(" nano help text\n\n " /* Default to the main help list. */
htx = N_(" nano help text\n\n "
"The nano editor is designed to emulate the functionality and " "The nano editor is designed to emulate the functionality and "
"ease-of-use of the UW Pico text editor. There are four main " "ease-of-use of the UW Pico text editor. There are four main "
"sections of the editor: The top line shows the program " "sections of the editor: The top line shows the program "
@ -385,14 +387,16 @@ void help_init(void)
"The following keystrokes are available in the main editor " "The following keystrokes are available in the main editor "
"window. Alternative keys are shown in parentheses:\n\n"); "window. Alternative keys are shown in parentheses:\n\n");
allocsize += strlen(ptr); htx = _(htx);
allocsize += strlen(htx);
/* The space needed for the shortcut lists, at most COLS characters, /* The space needed for the shortcut lists, at most COLS characters,
* plus '\n'. */ * plus '\n'. */
allocsize += (COLS + 1) * length_of_list(currshortcut); allocsize += (COLS + 1) * length_of_list(currshortcut);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* If we're on the main list, we also count the toggle help text. /* If we're on the main list, we also count the toggle help text.
* Each line has "M-%c\t\t\t", which fills 24 columns, plus at most * Each line has "M-%c\t\t\t", which fills 24 columns, plus at most
* COLS - 24 characters, plus '\n'.*/ * COLS - 24 characters, plus '\n'.*/
if (currshortcut == main_list) { if (currshortcut == main_list) {
@ -407,17 +411,18 @@ void help_init(void)
* while in the help screen. */ * while in the help screen. */
free(help_text); free(help_text);
/* Allocate space for the help text */ /* Allocate space for the help text. */
help_text = charalloc(allocsize); help_text = charalloc(allocsize);
/* Now add the text we want */ /* Now add the text we want. */
strcpy(help_text, ptr); strcpy(help_text, htx);
ptr = help_text + strlen(help_text); ptr = help_text + strlen(help_text);
/* Now add our shortcut info */ /* Now add our shortcut info. */
for (s = currshortcut; s != NULL; s = s->next) { for (s = currshortcut; s != NULL; s = s->next) {
/* true if the character in s->metaval is shown in first column */
int meta_shortcut = FALSE; int meta_shortcut = FALSE;
/* TRUE if the character in s->metaval is shown in the
* first column. */
if (s->ctrlval != NANO_NO_KEY) { if (s->ctrlval != NANO_NO_KEY) {
#ifndef NANO_SMALL #ifndef NANO_SMALL
@ -472,7 +477,7 @@ void help_init(void)
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
/* If all went well, we didn't overwrite the allocated space for /* If all went well, we didn't overwrite the allocated space for
help_text. */ * help_text. */
assert(strlen(help_text) < allocsize); assert(strlen(help_text) < allocsize);
} }
#endif #endif
@ -626,7 +631,7 @@ void print1opt(const char *shortflag, const char *longflag, const char
printf("\t"); printf("\t");
#endif #endif
printf("%s\n", desc); printf("%s\n", _(desc));
} }
void usage(void) void usage(void)
@ -639,69 +644,69 @@ void usage(void)
printf(_("Option\t\tMeaning\n")); printf(_("Option\t\tMeaning\n"));
#endif /* HAVE_GETOPT_LONG */ #endif /* HAVE_GETOPT_LONG */
print1opt("-h, -?", "--help", _("Show this message")); print1opt("-h, -?", "--help", N_("Show this message"));
print1opt(_("+LINE"), "", _("Start at line number LINE")); print1opt(_("+LINE"), "", N_("Start at line number LINE"));
#ifndef NANO_SMALL #ifndef NANO_SMALL
print1opt("-A", "--smarthome", _("Enable smart home key")); print1opt("-A", "--smarthome", N_("Enable smart home key"));
print1opt("-B", "--backup", _("Backup existing files on save")); print1opt("-B", "--backup", N_("Backup existing files on save"));
print1opt("-D", "--dos", _("Write file in DOS format")); print1opt("-D", "--dos", N_("Write file in DOS format"));
print1opt(_("-E [dir]"), _("--backupdir=[dir]"), _("Directory for writing backup files")); print1opt(_("-E [dir]"), _("--backupdir=[dir]"), N_("Directory for writing backup files"));
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
print1opt("-F", "--multibuffer", _("Enable multiple file buffers")); print1opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
#endif #endif
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
#ifndef NANO_SMALL #ifndef NANO_SMALL
print1opt("-H", "--historylog", _("Log & read search/replace string history")); print1opt("-H", "--historylog", N_("Log & read search/replace string history"));
#endif #endif
print1opt("-I", "--ignorercfiles", _("Don't look at nanorc files")); print1opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
print1opt("-M", "--mac", _("Write file in Mac format")); print1opt("-M", "--mac", N_("Write file in Mac format"));
print1opt("-N", "--noconvert", _("Don't convert files from DOS/Mac format")); print1opt("-N", "--noconvert", N_("Don't convert files from DOS/Mac format"));
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
print1opt(_("-Q [str]"), _("--quotestr=[str]"), _("Quoting string, default \"> \"")); print1opt(_("-Q [str]"), _("--quotestr=[str]"), N_("Quoting string, default \"> \""));
#endif #endif
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
print1opt("-R", "--regexp", _("Do regular expression searches")); print1opt("-R", "--regexp", N_("Do regular expression searches"));
#endif #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
print1opt("-S", "--smooth", _("Smooth scrolling")); print1opt("-S", "--smooth", N_("Smooth scrolling"));
#endif #endif
print1opt(_("-T [#cols]"), _("--tabsize=[#cols]"), _("Set width of a tab in cols to #cols")); print1opt(_("-T [#cols]"), _("--tabsize=[#cols]"), N_("Set width of a tab in cols to #cols"));
print1opt("-V", "--version", _("Print version information and exit")); print1opt("-V", "--version", N_("Print version information and exit"));
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
print1opt(_("-Y [str]"), _("--syntax [str]"), _("Syntax definition to use")); print1opt(_("-Y [str]"), _("--syntax [str]"), N_("Syntax definition to use"));
#endif #endif
print1opt("-Z", "--restricted", _("Restricted mode")); print1opt("-Z", "--restricted", N_("Restricted mode"));
print1opt("-c", "--const", _("Constantly show cursor position")); print1opt("-c", "--const", N_("Constantly show cursor position"));
#ifndef NANO_SMALL #ifndef NANO_SMALL
print1opt("-d", "--rebinddelete", _("Fix Backspace/Delete confusion problem")); print1opt("-d", "--rebinddelete", N_("Fix Backspace/Delete confusion problem"));
print1opt("-i", "--autoindent", _("Automatically indent new lines")); print1opt("-i", "--autoindent", N_("Automatically indent new lines"));
print1opt("-k", "--cut", _("Let ^K cut from cursor to end of line")); print1opt("-k", "--cut", N_("Cut from cursor to end of line"));
#endif #endif
print1opt("-l", "--nofollow", _("Don't follow symbolic links, overwrite")); print1opt("-l", "--nofollow", N_("Don't follow symbolic links, overwrite"));
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
print1opt("-m", "--mouse", _("Enable mouse")); print1opt("-m", "--mouse", N_("Enable mouse"));
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
print1opt(_("-o [dir]"), _("--operatingdir=[dir]"), _("Set operating directory")); print1opt(_("-o [dir]"), _("--operatingdir=[dir]"), N_("Set operating directory"));
#endif #endif
print1opt("-p", "--preserve", _("Preserve XON (^Q) and XOFF (^S) keys")); print1opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
#ifndef DISABLE_WRAPJUSTIFY #ifndef DISABLE_WRAPJUSTIFY
print1opt(_("-r [#cols]"), _("--fill=[#cols]"), _("Set fill cols to (wrap lines at) #cols")); print1opt(_("-r [#cols]"), _("--fill=[#cols]"), N_("Set fill cols to (wrap lines at) #cols"));
#endif #endif
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
print1opt(_("-s [prog]"), _("--speller=[prog]"), _("Enable alternate speller")); print1opt(_("-s [prog]"), _("--speller=[prog]"), N_("Enable alternate speller"));
#endif #endif
print1opt("-t", "--tempfile", _("Auto save on exit, don't prompt")); print1opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
print1opt("-v", "--view", _("View (read only) mode")); print1opt("-v", "--view", N_("View (read only) mode"));
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
print1opt("-w", "--nowrap", _("Don't wrap long lines")); print1opt("-w", "--nowrap", N_("Don't wrap long lines"));
#endif #endif
print1opt("-x", "--nohelp", _("Don't show help window")); print1opt("-x", "--nohelp", N_("Don't show help window"));
print1opt("-z", "--suspend", _("Enable suspend")); print1opt("-z", "--suspend", N_("Enable suspend"));
/* This is a special case. */ /* This is a special case. */
printf(" %s\t\t\t%s\n","-a, -b, -e, -f, -g, -j", _("(ignored, for Pico compatibility)")); printf(" %s\t\t\t%s\n","-a, -b, -e, -f, -g, -j", _("(ignored, for Pico compatibility)"));