Skip to content

Commit

Permalink
[wip #52, #36] mark strings for translation
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Dec 31, 2017
1 parent 37cb193 commit d8891ae
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 56 deletions.
40 changes: 23 additions & 17 deletions hldig/ExternalParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ ExternalParser::parse (Retriever & retriever, URL & base)
(loc = atoi (token2)) >= 0 && (hd = atoi (token3)) >= 0 && hd < 12)
retriever.got_word (token1, loc, hd);
else
cerr << "External parser error: expected word in line " << line <<
cerr << _("External parser error: expected word in line ") << line <<
"\n" << " URL: " << base.get () << "\n";
break;

Expand All @@ -355,16 +355,16 @@ ExternalParser::parse (Retriever & retriever, URL & base)
retriever.got_href (url, token2);
}
else
cerr << "External parser error: expected URL in line " << line << "\n"
<< " URL: " << base.get () << "\n";
cerr << _("External parser error: expected URL in line ") << line << "\n"
<< _(" URL: ") << base.get () << "\n";
break;

case 't': // title
token1 = strtok (0, "\t");
if (token1 != NULL)
retriever.got_title (token1);
else
cerr << "External parser error: expected title in line " << line <<
cerr << _("External parser error: expected title in line ") << line <<
"\n" << " URL: " << base.get () << "\n";
break;

Expand All @@ -373,26 +373,26 @@ ExternalParser::parse (Retriever & retriever, URL & base)
if (token1 != NULL)
retriever.got_head (token1);
else
cerr << "External parser error: expected text in line " << line <<
"\n" << " URL: " << base.get () << "\n";
cerr << _("External parser error: expected text in line ") << line <<
"\n" << _(" URL: ") << base.get () << "\n";
break;

case 'a': // anchor
token1 = strtok (0, "\t");
if (token1 != NULL)
retriever.got_anchor (token1);
else
cerr << "External parser error: expected anchor in line " << line <<
"\n" << " URL: " << base.get () << "\n";
cerr << _("External parser error: expected anchor in line ") << line <<
"\n" << _(" URL: ") << base.get () << "\n";
break;

case 'i': // image url
token1 = strtok (0, "\t");
if (token1 != NULL)
retriever.got_image (token1);
else
cerr << "External parser error: expected image URL in line " << line
<< "\n" << " URL: " << base.get () << "\n";
cerr << _("External parser error: expected image URL in line ") << line
<< "\n" << _(" URL: ") << base.get () << "\n";
break;

case 'm': // meta
Expand Down Expand Up @@ -541,14 +541,14 @@ ExternalParser::parse (Retriever & retriever, URL & base)
}
}
else
cerr << "External parser error: expected metadata in line " << line
<< "\n" << " URL: " << base.get () << "\n";
cerr << _("External parser error: expected metadata in line ") << line
<< "\n" << _(" URL: ") << base.get () << "\n";
break;
}

default:
cerr << "External parser error: unknown field in line " << line << "\n"
<< " URL: " << base.get () << "\n";
cerr << _("External parser error: unknown field in line ") << line << "\n"
<< _(" URL: ") << base.get () << "\n";
break;
}
} // while(readLine)
Expand All @@ -558,11 +558,17 @@ ExternalParser::parse (Retriever & retriever, URL & base)
mystrncasecmp ((char *) convertToType, "text/", 5) != 0)
{
if (mystrcasecmp ((char *) convertToType, "user-defined") == 0)
cerr << "External parser error: no Content-Type given\n";
{
// TRANSLATORS: Do not translate "Content-Type"
cerr << _("External parser error: no Content-Type given\n");
}
else
cerr << "External parser error: can't parse Content-Type \""
{
// TRANSLATORS: Do not translate "Content-Type"
cerr << _("External parser error: can't parse Content-Type \"")
<< convertToType << "\"\n";
cerr << " URL: " << base.get () << "\n";
}
cerr << _(" URL: ") << base.get () << "\n";
}
else
{
Expand Down
28 changes: 14 additions & 14 deletions hldig/ExternalTransport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ Transport::DocStatus ExternalTransport::Request ()
if (token1 != NULL)
_Response->_status_code = atoi (token1);
else
cerr << "External transport error: expected status code in line " <<
line << "\n" << " URL: " << _URL.get () << "\n";
cerr << _("External transport error: expected status code in line ") <<
line << "\n" << _(" URL: ") << _URL.get () << "\n";
break;

case 'r': // status reason
token1 = strtok (0, "\t");
if (token1 != NULL)
_Response->_reason_phrase = token1;
else
cerr << "External transport error: expected status reason in line " <<
line << "\n" << " URL: " << _URL.get () << "\n";
cerr << _("External transport error: expected status reason in line ") <<
line << "\n" << _(" URL: ") << _URL.get () << "\n";
break;

case 'm': // modification time
Expand All @@ -260,40 +260,40 @@ Transport::DocStatus ExternalTransport::Request ()
_Response->_modification_time = NewDate (token1); // Hopefully we can grok it...
else
cerr <<
"External transport error: expected modification time in line " <<
line << "\n" << " URL: " << _URL.get () << "\n";
_("External transport error: expected modification time in line ") <<
line << "\n" << _(" URL: ") << _URL.get () << "\n";
break;

case 't': // Content-Type
token1 = strtok (0, "\t");
if (token1 != NULL)
_Response->_content_type = token1;
else
cerr << "External transport error: expected content-type in line " <<
line << "\n" << " URL: " << _URL.get () << "\n";
cerr << _("External transport error: expected content-type in line ") <<
line << "\n" << _(" URL: ") << _URL.get () << "\n";
break;

case 'l': // Content-Length
token1 = strtok (0, "\t");
if (token1 != NULL)
_Response->_content_length = atoi (token1);
else
cerr << "External transport error: expected content-length in line "
<< line << "\n" << " URL: " << _URL.get () << "\n";
cerr << _("External transport error: expected content-length in line ")
<< line << "\n" << _(" URL: ") << _URL.get () << "\n";
break;

case 'u': // redirect target
token1 = strtok (0, "\t");
if (token1 != NULL)
_Response->_location = token1;
else
cerr << "External transport error: expected URL in line " << line <<
"\n" << " URL: " << _URL.get () << "\n";
cerr << _("External transport error: expected URL in line ") << line <<
"\n" << _(" URL: ") << _URL.get () << "\n";
break;

default:
cerr << "External transport error: unknown field in line " << line <<
"\n" << " URL: " << _URL.get () << "\n";
cerr << _("External transport error: unknown field in line ") << line <<
"\n" << _(" URL: ") << _URL.get () << "\n";
break;
}
}
Expand Down
37 changes: 19 additions & 18 deletions hldig/Retriever.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ sig_handlers (void)
sigemptyset (&action.sa_mask);
action.sa_flags = 0;
if (sigaction (SIGINT, &action, NULL) != 0)
reportError ("Cannot install SIGINT handler\n");
reportError (_("Cannot install SIGINT handler\n"));
if (sigaction (SIGQUIT, &action, NULL) != 0)
reportError ("Cannot install SIGQUIT handler\n");
reportError (_("Cannot install SIGQUIT handler\n"));
if (sigaction (SIGTERM, &action, NULL) != 0)
reportError ("Cannot install SIGTERM handler\n");
reportError (_("Cannot install SIGTERM handler\n"));
if (sigaction (SIGHUP, &action, NULL) != 0)
reportError ("Cannot install SIGHUP handler\n");
reportError (_("Cannot install SIGHUP handler\n"));
#else
//ANSI C signal handling - Limited to supported Windows signals.
signal (SIGINT, sigexit);
Expand All @@ -312,7 +312,7 @@ sig_phandler (void)
action.sa_handler = sigpipe;
action.sa_flags = SA_RESTART;
if (sigaction (SIGPIPE, &action, NULL) != 0)
reportError ("Cannot install SIGPIPE handler\n");
reportError (_("Cannot install SIGPIPE handler\n"));
#endif //_MSC_VER /* _WIN32 */
}

Expand Down Expand Up @@ -557,7 +557,7 @@ Retriever::Start ()
if (0 == urls_parsed)
{
reportError (form
("Unable to create URL log file '%s'", filelog.get ()));
(_("Unable to create URL log file '%s'"), filelog.get ()));
}
else
{
Expand Down Expand Up @@ -1991,15 +1991,15 @@ Retriever::recordNotFound (const String & url, const String & referer,
switch (reason)
{
case Transport::Document_not_found:
message = "Not found";
message = _("Not found");
break;

case Transport::Document_no_host:
message = "Unknown host or unable to contact server";
message = _("Unknown host or unable to contact server");
break;

case Transport::Document_no_port:
message = "Unknown host or unable to contact server (port)";
message = _("Unknown host or unable to contact server (port)");
break;

default:
Expand All @@ -2017,11 +2017,11 @@ void
Retriever::ReportStatistics (const String & name)
{
HtConfiguration *config = HtConfiguration::config ();
cout << name << ": Run complete\n";
cout << name << ": " << servers.Count () << " server";
cout << name << _(": Run complete\n");
cout << name << ": " << servers.Count () << _(" server");
if (servers.Count () > 1)
cout << "s";
cout << " seen:\n";
cout << _(" seen:\n");

Server *server;
String buffer;
Expand All @@ -2046,28 +2046,29 @@ Retriever::ReportStatistics (const String & name)

if (notFound.length () > 0)
{
cout << "\n" << name << ": Errors to take note of:\n";
cout << "\n" << name << _(": Errors to take note of:\n");
cout << notFound;
}

cout << endl;

// Report HTTP connections stats
cout << "HTTP statistics" << endl;
cout << _("HTTP statistics") << endl;
cout << "===============" << endl;

if (config->Boolean ("persistent_connections"))
{
cout << " Persistent connections : Yes" << endl;
cout << _(" Persistent connections : Yes") << endl;

// TRANSLATORS: I do not think "HEAD" or "GET" should be translated.
if (config->Boolean ("head_before_get"))
cout << " HEAD call before GET : Yes" << endl;
cout << _(" HEAD call before GET : Yes") << endl;
else
cout << " HEAD call before GET : No" << endl;
cout << _(" HEAD call before GET : No") << endl;
}
else
{
cout << " Persistent connections : No" << endl;
cout << _(" Persistent connections : No") << endl;
}

HtHTTP::ShowStatistics (cout) << endl;
Expand Down
2 changes: 1 addition & 1 deletion hldig/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void
Server::reportStatistics (String & out, char *name)
{
out << name << " " << _host << ":" << _port;
out << " " << _documents << " document";
out << " " << _documents << _(" document");
if (_documents != 1)
out << "s";
}
4 changes: 4 additions & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

htcommon/messages.cc
hldig/hldig.cc
hldig/Retriever.cc
hldig/Server.cc
hldig/ExternalParser.cc
hldig/ExternalTransport.cc
hlsearch/hlsearch.cc
httools/htdump.cc
httools/htload.cc
Expand Down
Loading

0 comments on commit d8891ae

Please sign in to comment.