solbu / hldig

hl://Dig is a fork of ht://Dig, a web indexing and searching system for a small domain or intranet
https://solbu.github.io/hldig/
Other
18 stars 21 forks source link

create htcommon/messages.cc for common messages #41

Open andy5995 opened 6 years ago

andy5995 commented 6 years ago

If you run ack "Verbose mode. This increases the verbosity of the" you'll see a lot of the same messages in several files.

So for example, this code:

    cout << "\t-v\tVerbose mode.  This increases the verbosity of the\n";
    cout << "\t\tprogram.  Using more than 2 is probably only useful\n";
    cout << "\t\tfor debugging purposes.  The default verbose mode\n";

Could go into htcommon/messages.c and all the other programs that use it could call a variable containing the contents of the string in that file.

And actually, to help with preparing the source for translating, instead of using "cout" we'll do this:

  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 while digging.\n\n"));

@AlexChristoforides would you be interested in working on this?

ghost commented 6 years ago

@andy5995 Yeah! I’ll look into it. I’m a little busy at the moment, but I’ll work on it later tonight!

andy5995 commented 6 years ago

So these are the files where you'll be removing messages

htdig/htdig.cc htsearch/htsearch.cc htsearch/qtest.cc htsearch/parsetest.cc httools/htmerge.cc httools/htdump.cc httools/htstat.cc httools/htpurge.cc httools/htload.cc

You'll notice in htdig.cc that some of the cout statements have been changed to printf statements, and that _( and a closing parens has been added to some of the strings.

That's related to the translation process. _(String) is defined in htdig.h

#include "gettext.h"
#define _(String) gettext (String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)

Using the gettext library, one would use gettext(String) but using the _ shortens that. The calls to are strings that will get translated.

So that's the short explanation. What that means for you...

That block above would have to be moved to a header file that all the .cc files I mentioned loads. I'm thinking HtConfiguration.h would be the best place for it. It can then be removed from htdig.h.

If you can suggest a better place for it, please do so.

These three lines that follow main() must be added to each of the .cc files in the list above: https://github.com/andy5995/htdig/blob/e49f1cfa3a889a05fba0e21b4fc49d384500a22b/htdig/htdig.cc#L78-L82

That basically allows gettext to work.

Once that's done, it'll be a matter of editing the Makefiles, so just let me know when you've prepared the sources as described above. Or let me know if you get stuck.

And let me know if you change your mind about working on this ;)

andy5995 commented 6 years ago

I have to correct myself on some of what I said above. That will all help to prepare the sources for translation, but since the translated strings at present will only be in messages.c and htdig.cc, that would not all be necessary. gettext would only need to be triggered in messages.c.

But as I said, it will help prepare the sources for translating. Soon, each of those .cc files will also need to be able to use gettext and the _(String) definition.

ghost commented 6 years ago

@andy5995 I believe that the location for the code snippet above is perfectly suitable to be located in HtConfiguration.cc!

andy5995 commented 6 years ago

I did part of this in https://github.com/andy5995/hldig/commit/37918a229e0b62a03bcc83f4a470ad50e63d3e0e#diff-188bae5413d3f35e5347962b8c9c47bd