Skip to content

Commit

Permalink
[wip #52] change formatting of help output
Browse files Browse the repository at this point in the history
Also, I marked more strings in more files for translation.
  • Loading branch information
andy5995 committed Dec 30, 2017
1 parent e0a9657 commit 0c02d50
Show file tree
Hide file tree
Showing 14 changed files with 801 additions and 324 deletions.
78 changes: 43 additions & 35 deletions hldig/hldig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ main (int ac, char **av)
images_seen = fopen (filename, initial ? "w" : "a");
if (images_seen == 0)
{
reportError (form ("Unable to create images file '%s'",
reportError (form (_("Unable to create images file '%s'"),
filename.get ()));
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ main (int ac, char **av)

if (docs.Open (filename, index_filename, head_filename) < 0)
{
reportError (form ("Unable to open/create document database '%s'",
reportError (form (_("Unable to open/create document database '%s'"),
filename.get ()));
}

Expand Down Expand Up @@ -375,6 +375,8 @@ main (int ac, char **av)

// Handle list of URLs given in a file (stdin, if "-") specified as
// argument to -m or as an optional trailing argument.

// FIXME: this string needs changing for use with getttext //
if (optind < ac)
{
if (debug)
Expand Down Expand Up @@ -414,6 +416,7 @@ main (int ac, char **av)
else
{
cerr << "Could not open argument '" << minimalFile << "' of flag -m\n";
// fprintf (stderr, _("Could not open argument '%s' of flag -m\n"), minimalFile.c_str());
exit (1);
}
}
Expand Down Expand Up @@ -488,42 +491,47 @@ Options:\n"), VERSION);

help.verbose ();

printf (_("\t-i\tInitial. Do not use any old databases. This is\n\
\t\taccomplished by first erasing the databases.\n\n"));
printf (_("\
-i\tInitial. Do not use any old databases. This is\n\
\taccomplished by first erasing the databases.\n\n"));

help.config ();

printf (_("\t-t\tCreate an ASCII version of the document database.\n\
\t\tThis database is easy to parse with other programs so\n\
\t\tthat information can be extracted from it.\n\n"));

printf (_("\t-h hop count\n\
\t\tLimit the stored documents to those which are at\n\
\t\tmost hopcount links away from the start URL.\n\n"));

printf (_("\t-s\tReport statistics after completion.\n\n"));

printf (_("\t-u username:password\n\
\t\tTells hldig to send the supplied username and\n\
\t\tpassword with each HTTP request. The credentials\n\
\t\twill be encoded using the 'Basic' authentication scheme.\n\
\t\tThere *HAS* to be a colon (:) between the username\n\
\t\tand password.\n\n"));

printf (_("\t-a\tUse alternate work files.\n\
\t\tTells hldig to append .work to database files, causing\n\
\t\ta second copy of the database to be built. This allows\n\
\t\tthe original files to be used by htsearch during the\n\
\t\tindexing run.\n\n"));

printf (_("\t-m minimalfile (or just a file name at end of arguments)\n\
\t\tTells hldig to read URLs from the supplied file and index\n\
\t\tthem in place of (or in addition to) the existing URLs in\n\
\t\tthe database and the start_url. With the -m, only the\n\
\t\tURLs specified are added to the database. A file name of\n\
\t\t'-' indicates the standard input.\n\n"));


printf (_("\
-t\tCreate an ASCII version of the document database.\n\
\tThis database is easy to parse with other programs so\n\
\tthat information can be extracted from it.\n\n"));

printf (_("\
-h\thop count\n\
\tLimit the stored documents to those which are at\n\
\tmost hopcount links away from the start URL.\n\n"));

printf (_("\
-s\tReport statistics after completion.\n\n"));

printf (_("\
-u\tusername:password\n\
\tTells hldig to send the supplied username and\n\
\tpassword with each HTTP request. The credentials\n\
\twill be encoded using the 'Basic' authentication scheme.\n\
\tThere *HAS* to be a colon (:) between the username\n\
\tand password.\n\n"));

printf (_("\
-a\tUse alternate work files.\n\
\tTells hldig to append .work to database files, causing\n\
\ta second copy of the database to be built. This allows\n\
\tthe original files to be used by hlsearch during the\n\
\tindexing run.\n\n"));

printf (_("\
-m\tminimalfile (or just a file name at end of arguments)\n\
\tTells hldig to read URLs from the supplied file and index\n\
\tthem in place of (or in addition to) the existing URLs in\n\
\tthe database and the start_url. With the -m, only the\n\
\tURLs specified are added to the database. A file name of\n\
\t'-' indicates the standard input.\n\n"));

exit (0);
}
Expand Down
38 changes: 20 additions & 18 deletions hlsearch/hlsearch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ main (int ac, char **av)
//
config->Defaults (&defaults[0]);
// To allow . in filename while still being 'secure',
// e.g. htdig-f.q.d.n.conf
// e.g. hldig-f.q.d.n.conf
if (!override_config && config_name
&& (strstr (config_name, "./") == NULL))
{
Expand All @@ -231,7 +231,7 @@ main (int ac, char **av)
}
if (access ((char *) configFile, R_OK) < 0)
{
reportError ("Unable to read configuration file");
reportError (_("Unable to read configuration file"));
}
config->Read (configFile);

Expand Down Expand Up @@ -324,14 +324,14 @@ main (int ac, char **av)
String url_part_errors = HtURLCodec::instance ()->ErrMsg ();

if (url_part_errors.length () != 0)
reportError (form ("Invalid url_part_aliases or common_url_parts: %s",
reportError (form (_("Invalid url_part_aliases or common_url_parts: %s"),
url_part_errors.get ()));

// for hlsearch, use search_rewrite_rules attribute for HtURLRewriter.
config->AddParsed ("url_rewrite_rules", "${search_rewrite_rules}");
url_part_errors = HtURLRewriter::instance ()->ErrMsg ();
if (url_part_errors.length () != 0)
reportError (form ("Invalid url_rewrite_rules: %s",
reportError (form (_("Invalid url_rewrite_rules: %s"),
url_part_errors.get ()));

// Load boolean_keywords from configuration
Expand All @@ -342,7 +342,7 @@ main (int ac, char **av)
boolean_keywords.Create (config->Find ("boolean_keywords"),
"| \t\r\n\001");
if (boolean_keywords.Count () != 3)
reportError ("boolean_keywords attribute should have three entries");
reportError (_("boolean_keywords attribute should have three entries"));

Parser *parser = new Parser ();

Expand Down Expand Up @@ -390,7 +390,7 @@ main (int ac, char **av)
if (access (word_db, R_OK) < 0)
{
reportError (form
("Unable to read word database file '%s'\nDid you run htdig?",
(_("Unable to read word database file '%s'\nDid you run hldig?"),
word_db.get ()));
}
// ResultList *results = htsearch((char*)word_db, searchWords, parser);
Expand All @@ -399,23 +399,23 @@ main (int ac, char **av)
if (access ((char *) doc_index, R_OK) < 0)
{
reportError (form
("Unable to read document index file '%s'\nDid you run htdig?",
(_("Unable to read document index file '%s'\nDid you run hldig?"),
doc_index.get ()));
}

const String doc_db = config->Find ("doc_db");
if (access (doc_db, R_OK) < 0)
{
reportError (form
("Unable to read document database file '%s'\nDid you run htdig?",
(_("Unable to read document database file '%s'\nDid you run hldig?"),
doc_db.get ()));
}

const String doc_excerpt = config->Find ("doc_excerpt");
if (access (doc_excerpt, R_OK) < 0)
{
reportError (form
("Unable to read document excerpts '%s'\nDid you run htdig?",
(_("Unable to read document excerpts '%s'\nDid you run hldig?"),
doc_excerpt.get ()));
}

Expand All @@ -442,7 +442,7 @@ main (int ac, char **av)
Display display (&selected_collections);
if (display.hasTemplateError ())
{
reportError (form ("Unable to read template file '%s'\nDoes it exist?",
reportError (form (_("Unable to read template file '%s'\nDoes it exist?"),
(const char *) config->Find ("template_name")));
return 0;
}
Expand Down Expand Up @@ -953,12 +953,13 @@ reportError (char *msg)
cout << "Content-type: text/html\r\n\r\n";
cout << "<html><head><title>hlsearch error</title></head>\n";
cout << "<body bgcolor=\"#ffffff\">\n";
cout << "<h1>hl://Dig error</h1>\n";
cout << "<p>hlsearch detected an error. Please report this to the\n";
cout << "webmaster of this site by sending an e-mail to:\n";

printf (_("<h1>hl://Dig error</h1>\n\
<p>hlsearch detected an error. Please report this to the\n\
webmaster of this site by sending an e-mail to:\n"));
cout << "<a href=\"mailto:" << config->Find ("maintainer") << "\">";
cout << config->Find ("maintainer") << "</a>\n";
cout << "The error message is:</p>\n";
cout << _("The error message is:</p>\n");
cout << "<pre>\n" << msg << "\n</pre>\n</body></html>\n";
exit (1);
}
Expand All @@ -980,9 +981,10 @@ This program is part of hl://Dig %s\n\n"), VERSION);
help.config ();

cout << _("\
\tquery_string\tA CGI-style query string can be given as a single\n\
\t\targument, and is only used if the REQUEST_METHOD environment\n\
\t\tvariable is not set. If no query_string is given, and\n\
\t\tREQUEST_METHOD is not set, hlsearch will prompt for the query.\n\n");
query_string\n\
\tA CGI-style query string can be given as a single\n\
\targument, and is only used if the REQUEST_METHOD environment\n\
\tvariable is not set. If no query_string is given, and\n\
\tREQUEST_METHOD is not set, hlsearch will prompt for the query.\n\n");
exit (0);
}
19 changes: 11 additions & 8 deletions htcommon/messages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@
#include "messages.h"

void Usage::verbose (void) {
printf (_("\t-v\tVerbose mode. This increases the verbosity of the\n\
\t\tprogram. Using more than 2 is probably only useful\n\
\t\tfor debugging purposes. The default verbose mode\n\
\t\tgives a nice progress report of what it is doing and\n\
\t\twhere it is.\n\n"));
printf (_("\
-v\tVerbose mode\n\
\tThis increases the verbosity of the\n\
\tprogram. Using more than 2 is probably only useful\n\
\tfor debugging purposes. The default verbose mode\n\
\tgives a nice progress report of what it is doing and\n\
\twhere it is.\n\n"));
}

void Usage::config (void) {

printf (_("\t-c configfile\n\
\t\tUse the specified configuration file instead of the\n\
\t\tdefault.\n\n"));
printf (_("\
-c\tconfigfile\n\
\tUse the specified configuration file instead of the\n\
\tdefault.\n\n"));
}

Usage::Usage (void) {}
Expand Down
Loading

0 comments on commit 0c02d50

Please sign in to comment.