Re: Patch for I18N support: how to incorporate?
Jan-Oliver Wagner <[email protected]>
| Newsgroups | gmane.comp.security.nessus.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 17, 2004 at 11:53:32PM +0200, Renaud Deraison wrote: > On Tue, Aug 17, 2004 at 03:32:27PM +0200, Jan-Oliver Wagner wrote: > > 2. Should I split up the patch into a series of > > small patches to test separately? > > Yes please. here is the first patch. It has to be applied to nessus-core/nessus. I regard it harmless. Nothing will happen to you before changes are made to configure.in and nessus.tmpl.in. I am used to write detailed ChangeLog entries. I noticed that this is not done yet for nessus. However, I wrote a ChangeLog entry for better understanding. Maybe you find it useful and add it as nessus-core/ChangeLog. At least it is good for commit messages. Best Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ _______________________________________________ Nessus-devel mailing list [email protected] http://mail.nessus.org/mailman/listinfo/nessus-devel
ChangeLog
(text/plain, 517 B)
2004-08-18 Jan-Oliver Wagner <[email protected]> Introduce I18N support. Only one string marked so far for testing. * nessus/Makefile (cflags): Added definition of PACKAGE=nessus for gettext. * nessus/nessus.h: Added definition of function _() depending on whether gettext is available or not. In the latter case _(a) is just (a). * nessus/nessus.c (i18n_init): New. Binds the text domain in case gettext is available. (main): Call i18n_init() right after start. Applied _() to a single sample string.
nessus-i18n-patch1
(text/plain, 2.3 KB)
Index: Makefile
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/Makefile,v
retrieving revision 1.52
diff -u -3 -p -r1.52 Makefile
--- Makefile 22 Feb 2003 13:47:43 -0000 1.52
+++ Makefile 18 Aug 2004 07:56:16 -0000
@@ -67,7 +67,7 @@ ${make_bindir}/nessus : cflags nessus
cflags :
- @echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) $(INCLUDE)" | sed 's/\"/\\\"/g' > cflags.tmp
+ @echo "$(NESSUS_CFLAGS) $(NESSUS_DEFS) -DPACKAGE=\"nessus\" $(INCLUDE)" | sed 's/\"/\\\"/g' > cflags.tmp
@echo "echo \"`cat cflags.tmp`\"" > cflags
@rm cflags.tmp
@chmod +x cflags
Index: nessus.c
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nessus.c,v
retrieving revision 1.170
diff -u -3 -p -r1.170 nessus.c
--- nessus.c 17 Feb 2004 16:08:22 -0000 1.170
+++ nessus.c 18 Aug 2004 07:56:16 -0000
@@ -130,6 +130,18 @@ int ListOnly = 0;
void init_globals();
+/*
+ * Initialize I18N support, if possible
+ */
+static void
+i18n_init(void)
+{
+#ifdef HAVE_GNU_GETTEXT
+ setlocale (LC_ALL, "" );
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+#endif
+}
#ifdef NESSUS_ON_SSL
@@ -805,18 +817,19 @@ int main(int argc, char * argv[])
int opt_o= 0;
char * inf = NULL, *outf = NULL;
+ /* Setup I18N. */
+ i18n_init();
+
/*
* Version check
*/
-
-
if(version_check(NESSUS_VERSION, nessuslib_version())>0)
{
fprintf(stderr,
-"Error : we are linked against nessus-libraries %s. \n\
+_("Error : we are linked against nessus-libraries %s. \n\
Install nessus-libraries %s or make sure that\n\
-you have deleted older versions nessus libraries from your system\n",
+you have deleted older versions nessus libraries from your system\n"),
nessuslib_version(), NESSUS_VERSION);
}
Index: nessus.h
===================================================================
RCS file: /usr/local/cvs/nessus-core/nessus/nessus.h,v
retrieving revision 1.24
diff -u -3 -p -r1.24 nessus.h
--- nessus.h 29 Sep 2003 14:52:27 -0000 1.24
+++ nessus.h 18 Aug 2004 07:56:16 -0000
@@ -40,4 +40,11 @@ extern int init_directories;
char * connect_to_nessusd(char *, int, char *, char *);
+#ifdef HAVE_GNU_GETTEXT
+# include <libintl.h>
+# define _(a) gettext (a)
+#else
+# define _(a) (a)
+#endif /*HAVE_GNU_GETTEXT*/
+
#endif