[sugj-tech:1840] SWAT internatinalization project is working

Ryo Kawahara rkawa at lbe.co.jp
Tue Oct 24 11:02:42 GMT 2000


Hi all. I send a patch to samba-patches at samba.org that
enables output messages of SWAT, smbclient, testparm,
make_unicodemap and smbstatus to be internationalized.

http://samba.org/samba-patches?findid=187

This patch applies to cvs SAMBA_2_2 of Oct, 24.
The patch is very big (400KB) including GNU gettext source code,
autoconf support and message catalog templates.

The attachment of this email is a sample of message i18n.
Most of the lines of C source code we modified looks like:

-printf("hoge");
+printf(_("hoge"))

where _("hoge") invokes gettext() function. the function searches
traslated version of string "hoge" if message catalog file is
available.
Sample message catalogs can be downloaded from:
http://ftp3.lbe.co.jp/~rkawa/samba-2.2-l10n-ja-20001020.tar.gz
http://ftp3.lbe.co.jp/~rkawa/samba-2.2-l10n-en-20001020.tar.gz
(this server might be slow, I will put them into samba.gr.jp server later)

Only samples of English and Japanese message catalogs are available now,
but it will not be difficult to make message catalog of other language
if you know gettext a little.
To use this feature, use --enable-nls configure option (ON by default).
If you don't use --disable-nls.

Another feature of this patch is language negotiation which is a 
part of http/1.1. SWAT now can detect web browser's language settings
and send the requested documents of preferred language if available.
This option can be ON by --with-i18n-swat configure option (OFF by default).
See
http://www.samba.gr.jp/project/samba-ja/
http://www.samba.gr.jp/project/samba-ja/install-guide.html
for web browser setting information.

Adding new language of is very easy. See
http://www.samba.gr.jp/project/samba-ja/add-lang.html
for detail, but installation method explained in the document is
obsolete, we have much easier way to do that. I'll write correct
document as soon as possible.
 
These functionalities of SWAT have been already used in Japanese version of
samba-2.0.7 and tested by Samba Users Group Japan on many platforms, so
I believe that portability of GNU gettext source and SWAT modification
have no problem. In addition, smbclient, make_unicodemap, smbstatus, testparm
i18n is done mainly by Mr.Miura (miura at samba.gr.jp).

The main purpose of this patch is to make development of l10n version
of Samba easier. Non-english speakers might want program outputs to be
written in their language, and want to use translated documents in web browser
or man pages.
This patch will enables that functionality.


# The attachment of this mail is only a sample of the patch.
# The whole set has been sent to samba-patches at samba.org.
http://samba.org/samba-patches?findid=187

From: "Ryo Kawahara" <rkawa at lbe.co.jp>
Subject: Re: [sugj-tech:1840] SWAT internatinalization project is working
Date: Sun, 8 Oct 2000 23:09:29 +0900

> Hello,...I'm making "internationalized" SWAT patch for 2.2.
> 
> ----- Original Message -----
> From: Hiroshi MIURA <miura at samba.gr.jp>
> To: <samba-technical at samba.org>
> Cc: <sugj-tech at samba.gr.jp>
> Sent: Sunday, October 08, 2000 4:12 PM
> Subject: [sugj-tech:1840] SWAT internatinalization project is working
> 
> 
> > Hi,
> >
> > I and Ryo Kawahara who is the members of Samba User Group Japan
> > are developing SWAT internationalization(I18N) using GNU gettext library.
> >
-------------- next part --------------
diff -uNr --exclude-from=patchexcl.txt samba/source/client/client.c samba-gt-i18n/source/client/client.c
--- samba/source/client/client.c	Fri Sep 15 01:47:49 2000
+++ samba-gt-i18n/source/client/client.c	Tue Oct 24 17:55:24 2000
@@ -22,6 +22,7 @@
 #define NO_SYSLOG
 
 #include "includes.h"
+#include "smbintl.h"
 
 #ifndef REGISTER
 #define REGISTER 0
@@ -174,7 +175,7 @@
 	}
 
 
-	printf("Connected. Type your message, ending it with a Control-D\n");
+	printf(_("Connected. Type your message, ending it with a Control-D\n"));
 
 	while (!feof(stdin) && total_len < 1600) {
 		int maxlen = MIN(1600 - total_len,127);
@@ -198,7 +199,7 @@
 		unix_to_dos(msg, True);
 
 		if (!cli_message_text(cli, msg, l, grp_id)) {
-			printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
+			printf(_("SMBsendtxt failed (%s)\n"),cli_errstr(cli));
 			return;
 		}      
 		
@@ -206,12 +207,12 @@
 	}
 
 	if (total_len >= 1600)
-		printf("the message was truncated to 1600 bytes\n");
+		printf(_("the message was truncated to 1600 bytes\n"));
 	else
-		printf("sent %d bytes\n",total_len);
+		printf(_("sent %d bytes\n"),total_len);
 
 	if (!cli_message_end(cli, grp_id)) {
-		printf("SMBsendend failed (%s)\n",cli_errstr(cli));
+		printf(_("SMBsendend failed (%s)\n"),cli_errstr(cli));
 		return;
 	}      
 }
@@ -226,11 +227,11 @@
 	int total, bsize, avail;
 
 	if (!cli_dskattr(cli, &bsize, &total, &avail)) {
-		DEBUG(0,("Error in dskattr: %s\n",cli_errstr(cli))); 
+		DEBUG(0,(_("Error in dskattr: %s\n"),cli_errstr(cli))); 
 		return;
 	}
 
-	DEBUG(0,("\n\t\t%d blocks of size %d. %d blocks available\n",
+	DEBUG(0,(_("\n\t\t%d blocks of size %d. %d blocks available\n"),
 		 total, bsize, avail));
 }
 
@@ -239,7 +240,7 @@
 ****************************************************************************/
 static void cmd_pwd(void)
 {
-	DEBUG(0,("Current directory is %s",service));
+	DEBUG(0,(_("Current directory is %s"),service));
 	DEBUG(0,("%s\n",cur_dir));
 }
 
@@ -290,7 +291,7 @@
 	if (next_token(NULL,buf,NULL,sizeof(buf)))
 		do_cd(buf);
 	else
-		DEBUG(0,("Current directory is %s\n",cur_dir));
+		DEBUG(0,(_("Current directory is %s\n"),cur_dir));
 }
 
 
@@ -303,7 +304,7 @@
 
 	if (*fileselection && 
 	    !mask_match(finfo->name,fileselection,False)) {
-		DEBUG(3,("match_match %s failed\n", finfo->name));
+		DEBUG(3,(_("match_match %s failed\n"), finfo->name));
 		return False;
 	}
 
@@ -511,7 +512,7 @@
 
 	if (in_do_list && rec)
 	{
-		fprintf(stderr, "INTERNAL ERROR: do_list called recursively when the recursive flag is true\n");
+		fprintf(stderr, _("INTERNAL ERROR: do_list called recursively when the recursive flag is true\n"));
 		exit(1);
 	}
 
@@ -1226,9 +1227,9 @@
 static void do_cancel(int job)
 {
 	if (cli_printjob_del(cli, job)) {
-		printf("Job %d cancelled\n",job);
+		printf(_("Job %d cancelled\n"),job);
 	} else {
-		printf("Error cancelling job %d : %s\n",job,cli_errstr(cli));
+		printf(_("Error cancelling job %d : %s\n"),job,cli_errstr(cli));
 	}
 }
 
@@ -1262,7 +1263,7 @@
 	char *p;
 
 	if (!next_token(NULL,lname,NULL, sizeof(lname))) {
-		DEBUG(0,("print <filename>\n"));
+		DEBUG(0,(_("print <filename>\n")));
 		return;
 	}
 
@@ -1310,7 +1311,7 @@
 		return;
 
 	if (!cli_unlink(cli, mask)) {
-		DEBUG(0,("%s deleting remote file %s\n",cli_errstr(cli),mask));
+		DEBUG(0,(_("%s deleting remote file %s\n"),cli_errstr(cli),mask));
 	}
 }
 
@@ -1329,7 +1330,7 @@
 	pstrcpy(mask,cur_dir);
 	
 	if (!next_token(NULL,buf,NULL,sizeof(buf))) {
-		DEBUG(0,("del <filename>\n"));
+		DEBUG(0,(_("del <filename>\n")));
 		return;
 	}
 	pstrcat(mask,buf);
@@ -1347,7 +1348,7 @@
 	pstrcpy(mask,cur_dir);
 	
 	if (!next_token(NULL,buf,NULL,sizeof(buf))) {
-		DEBUG(0,("del <filename>\n"));
+		DEBUG(0,(_("del <filename>\n")));
 		return;
 	}
 	pstrcat(mask,buf);
@@ -1367,13 +1368,13 @@
 	pstrcpy(mask,cur_dir);
 	
 	if (!next_token(NULL,buf,NULL,sizeof(buf))) {
-		DEBUG(0,("rmdir <dirname>\n"));
+		DEBUG(0,(_("rmdir <dirname>\n")));
 		return;
 	}
 	pstrcat(mask,buf);
 
 	if (!cli_rmdir(cli, mask)) {
-		DEBUG(0,("%s removing remote directory file %s\n",
+		DEBUG(0,(_("%s removing remote directory file %s\n"),
 			 cli_errstr(cli),mask));
 	}  
 }
@@ -1391,7 +1392,7 @@
 	
 	if (!next_token(NULL,buf,NULL,sizeof(buf)) || 
 	    !next_token(NULL,buf2,NULL, sizeof(buf2))) {
-		DEBUG(0,("rename <src> <dest>\n"));
+		DEBUG(0,(_("rename <src> <dest>\n")));
 		return;
 	}
 
@@ -1399,7 +1400,7 @@
 	pstrcat(dest,buf2);
 
 	if (!cli_rename(cli, src, dest)) {
-		DEBUG(0,("%s renaming files\n",cli_errstr(cli)));
+		DEBUG(0,(_("%s renaming files\n"),cli_errstr(cli)));
 		return;
 	}  
 }
@@ -1411,7 +1412,7 @@
 static void cmd_prompt(void)
 {
 	prompt = !prompt;
-	DEBUG(2,("prompting is now %s\n",prompt?"on":"off"));
+	DEBUG(2,(_("prompting is now %s\n"),prompt?"on":"off"));
 }
 
 
@@ -1427,14 +1428,14 @@
 	ok = next_token(NULL,buf,NULL,sizeof(buf));
 	if (ok && (sys_stat(buf,&sbuf) == 0)) {
 		newer_than = sbuf.st_mtime;
-		DEBUG(1,("Getting files newer than %s",
+		DEBUG(1,(_("Getting files newer than %s"),
 			 asctime(LocalTime(&newer_than))));
 	} else {
 		newer_than = 0;
 	}
 
 	if (ok && newer_than == 0)
-		DEBUG(0,("Error setting newer-than time\n"));
+		DEBUG(0,(_("Error setting newer-than time\n")));
 }
 
 /****************************************************************************
@@ -1447,7 +1448,7 @@
 	if (next_token(NULL,buf,NULL,sizeof(buf))) {
 		archive_level = atoi(buf);
 	} else
-		DEBUG(0,("Archive level is %d\n",archive_level));
+		DEBUG(0,(_("Archive level is %d\n"),archive_level));
 }
 
 /****************************************************************************
@@ -1456,7 +1457,7 @@
 static void cmd_lowercase(void)
 {
 	lowercase = !lowercase;
-	DEBUG(2,("filename lowercasing is now %s\n",lowercase?"on":"off"));
+	DEBUG(2,(_("filename lowercasing is now %s\n"),lowercase?"on":"off"));
 }
 
 
@@ -1468,7 +1469,7 @@
 static void cmd_recurse(void)
 {
 	recurse = !recurse;
-	DEBUG(2,("directory recursion is now %s\n",recurse?"on":"off"));
+	DEBUG(2,(_("directory recursion is now %s\n"),recurse?"on":"off"));
 }
 
 /****************************************************************************
@@ -1477,7 +1478,7 @@
 static void cmd_translate(void)
 {
 	translation = !translation;
-	DEBUG(2,("CR/LF<->LF and print text translation now %s\n",
+	DEBUG(2,(_("CR/LF<->LF and print text translation now %s\n"),
 		 translation?"on":"off"));
 }
 
@@ -1563,11 +1564,11 @@
 {
 	int ret;
 
-        printf("\n\tSharename      Type      Comment\n");
-        printf("\t---------      ----      -------\n");
+        printf(_("\n\tSharename      Type      Comment\n"));
+        printf(_("\t---------      ----      -------\n"));
 
 	if((ret = cli_RNetShareEnum(cli, browse_fn)) == -1)
-		printf("Error returning browse list: %s\n", cli_errstr(cli));
+		printf(_("Error returning browse list: %s\n"), cli_errstr(cli));
 
 	return (ret != -1);
 }
@@ -1587,13 +1588,13 @@
 {
 	if (!cli->server_domain) return False;
 
-        printf("\n\tServer               Comment\n");
-        printf("\t---------            -------\n");
+        printf(_("\n\tServer               Comment\n"));
+        printf(  _("\t---------            -------\n"));
 
 	cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn);
 
-        printf("\n\tWorkgroup            Master\n");
-        printf("\t---------            -------\n");
+        printf(_("\n\tWorkgroup            Master\n"));
+        printf(  _("\t---------            -------\n"));
 
 	cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn);
 	return True;
@@ -1627,58 +1628,60 @@
 #define COMPL_LOCAL       2          /* Complete local filename */
 
 /* This defines the commands supported by this client */
-struct
+struct commands_t
 {
   char *name;
   void (*fn)(void);
-  char *description;
+  char *description; 
   char compl_args[2];      /* Completion argument info */
-} commands[] = 
+};
+
+struct commands_t commands[] = 
 {
-  {"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
-  {"dir",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
-  {"du",cmd_du,"<mask> computes the total size of the current directory",{COMPL_REMOTE,COMPL_NONE}},
-  {"lcd",cmd_lcd,"[directory] change/report the local current working directory",{COMPL_LOCAL,COMPL_NONE}},
-  {"cd",cmd_cd,"[directory] change/report the remote directory",{COMPL_REMOTE,COMPL_NONE}},
-  {"pwd",cmd_pwd,"show current remote directory (same as 'cd' with no args)",{COMPL_NONE,COMPL_NONE}},
-  {"get",cmd_get,"<remote name> [local name] get a file",{COMPL_REMOTE,COMPL_LOCAL}},
-  {"mget",cmd_mget,"<mask> get all the matching files",{COMPL_REMOTE,COMPL_NONE}},
-  {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}},
-  {"mput",cmd_mput,"<mask> put all matching files",{COMPL_REMOTE,COMPL_NONE}},
-  {"rename",cmd_rename,"<src> <dest> rename some files",{COMPL_REMOTE,COMPL_REMOTE}},
-  {"more",cmd_more,"<remote name> view a remote file with your pager",{COMPL_REMOTE,COMPL_NONE}},  
-  {"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}},
-  {"del",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
-  {"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
-  {"rm",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
-  {"mkdir",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
-  {"md",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
-  {"rmdir",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
-  {"rd",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
-  {"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},  
-  {"recurse",cmd_recurse,"toggle directory recursion for mget and mput",{COMPL_NONE,COMPL_NONE}},  
-  {"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},  
-  {"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},  
-  {"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}},
-  {"printmode",cmd_printmode,"<graphics or text> set the print mode",{COMPL_NONE,COMPL_NONE}},
-  {"queue",cmd_queue,"show the print queue",{COMPL_NONE,COMPL_NONE}},
-  {"cancel",cmd_cancel,"<jobid> cancel a print queue entry",{COMPL_NONE,COMPL_NONE}},
-  {"quit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
-  {"q",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
-  {"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
-  {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
-  {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
-  {"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
-  {"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
+  {"ls",cmd_dir,N_("<mask> list the contents of the current directory"),{COMPL_REMOTE,COMPL_NONE}},
+  {"dir",cmd_dir,N_("<mask> list the contents of the current directory"),{COMPL_REMOTE,COMPL_NONE}},
+  {"du",cmd_du,N_("<mask> computes the total size of the current directory"),{COMPL_REMOTE,COMPL_NONE}},
+  {"lcd",cmd_lcd,N_("[directory] change/report the local current working directory"),{COMPL_LOCAL,COMPL_NONE}},
+  {"cd",cmd_cd,N_("[directory] change/report the remote directory"),{COMPL_REMOTE,COMPL_NONE}},
+  {"pwd",cmd_pwd,N_("show current remote directory (same as 'cd' with no args)"),{COMPL_NONE,COMPL_NONE}},
+  {"get",cmd_get,N_("<remote name> [local name] get a file"),{COMPL_REMOTE,COMPL_LOCAL}},
+  {"mget",cmd_mget,N_("<mask> get all the matching files"),{COMPL_REMOTE,COMPL_NONE}},
+  {"put",cmd_put,N_("<local name> [remote name] put a file"),{COMPL_LOCAL,COMPL_REMOTE}},
+  {"mput",cmd_mput,N_("<mask> put all matching files"),{COMPL_REMOTE,COMPL_NONE}},
+  {"rename",cmd_rename,N_("<src> <dest> rename some files"),{COMPL_REMOTE,COMPL_REMOTE}},
+  {"more",cmd_more,N_("<remote name> view a remote file with your pager"),{COMPL_REMOTE,COMPL_NONE}},  
+  {"mask",cmd_select,N_("<mask> mask all filenames against this"),{COMPL_REMOTE,COMPL_NONE}},
+  {"del",cmd_del,N_("<mask> delete all matching files"),{COMPL_REMOTE,COMPL_NONE}},
+  {"open",cmd_open,N_("<mask> open a file"),{COMPL_REMOTE,COMPL_NONE}},
+  {"rm",cmd_del,N_("<mask> delete all matching files"),{COMPL_REMOTE,COMPL_NONE}},
+  {"mkdir",cmd_mkdir,N_("<directory> make a directory"),{COMPL_NONE,COMPL_NONE}},
+  {"md",cmd_mkdir,N_("<directory> make a directory"),{COMPL_NONE,COMPL_NONE}},
+  {"rmdir",cmd_rmdir,N_("<directory> remove a directory"),{COMPL_NONE,COMPL_NONE}},
+  {"rd",cmd_rmdir,N_("<directory> remove a directory"),{COMPL_NONE,COMPL_NONE}},
+  {"prompt",cmd_prompt,N_("toggle prompting for filenames for mget and mput"),{COMPL_NONE,COMPL_NONE}},  
+  {"recurse",cmd_recurse,N_("toggle directory recursion for mget and mput"),{COMPL_NONE,COMPL_NONE}},  
+  {"translate",cmd_translate,N_("toggle text translation for printing"),{COMPL_NONE,COMPL_NONE}},  
+  {"lowercase",cmd_lowercase,N_("toggle lowercasing of filenames for get"),{COMPL_NONE,COMPL_NONE}},  
+  {"print",cmd_print,N_("<file name> print a file"),{COMPL_NONE,COMPL_NONE}},
+  {"printmode",cmd_printmode,N_("<graphics or text> set the print mode"),{COMPL_NONE,COMPL_NONE}},
+  {"queue",cmd_queue,N_("show the print queue"),{COMPL_NONE,COMPL_NONE}},
+  {"cancel",cmd_cancel,N_("<jobid> cancel a print queue entry"),{COMPL_NONE,COMPL_NONE}},
+  {"quit",cmd_quit,N_("logoff the server"),{COMPL_NONE,COMPL_NONE}},
+  {"q",cmd_quit,N_("logoff the server"),{COMPL_NONE,COMPL_NONE}},
+  {"exit",cmd_quit,N_("logoff the server"),{COMPL_NONE,COMPL_NONE}},
+  {"newer",cmd_newer,N_("<file> only mget files newer than the specified local file"),{COMPL_LOCAL,COMPL_NONE}},
+  {"archive",cmd_archive,N_("<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit"),{COMPL_NONE,COMPL_NONE}},
+  {"tar",cmd_tar,N_("tar <c|x>[IXFqbgNan] current directory to/from <file name>"),{COMPL_NONE,COMPL_NONE}},
+  {"blocksize",cmd_block,N_("blocksize <number> (default 20)"),{COMPL_NONE,COMPL_NONE}},
   {"tarmode",cmd_tarmode,
-     "<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
-  {"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
-  {"help",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
-  {"?",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
+    N_("<full|inc|reset|noreset> tar's behaviour towards archive bits"),{COMPL_NONE,COMPL_NONE}},
+  {"setmode",cmd_setmode,N_("filename <setmode string> change modes of file"),{COMPL_REMOTE,COMPL_NONE}},
+  {"help",cmd_help,N_("[command] give help on a command"),{COMPL_NONE,COMPL_NONE}},
+  {"?",cmd_help,N_("[command] give help on a command"),{COMPL_NONE,COMPL_NONE}},
 #ifdef HAVE_LIBREADLINE
-  {"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
+  {"history",cmd_history,N_("displays the command history"),{COMPL_NONE,COMPL_NONE}},
 #endif
-  {"!",NULL,"run a shell command on the local system",{COMPL_NONE,COMPL_NONE}},
+  {"!",NULL,N_("run a shell command on the local system"),{COMPL_NONE,COMPL_NONE}},
   {"",NULL,NULL,{COMPL_NONE,COMPL_NONE}}
 };
 
@@ -1723,7 +1726,7 @@
 	
 	if (next_token(NULL,buf,NULL,sizeof(buf))) {
 		if ((i = process_tok(buf)) >= 0)
-			DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));		    
+			DEBUG(0,(_("HELP %s:\n\t%s\n\n"),commands[i].name, _(commands[i].description)));		    
 	} else {
 		while (commands[i].description) {
 			for (j=0; commands[i].description && (j<5); j++) {
@@ -1917,13 +1920,13 @@
 	/* have to open a new connection */
 	if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) == 0) ||
 	    !cli_connect(c, server_n, &ip)) {
-		DEBUG(0,("Connection to %s failed\n", server_n));
+		DEBUG(0,(_("Connection to %s failed\n"), server_n));
 		return NULL;
 	}
 
 	if (!cli_session_request(c, &calling, &called)) {
 		char *p;
-		DEBUG(0,("session request to %s failed (%s)\n", 
+		DEBUG(0,(_("session request to %s failed (%s)\n"), 
 			 called.name, cli_errstr(c)));
 		cli_shutdown(c);
 		free(c);
@@ -1938,17 +1941,17 @@
 		return NULL;
 	}
 
-	DEBUG(4,(" session request ok\n"));
+	DEBUG(4,(_(" session request ok\n")));
 
 	if (!cli_negprot(c)) {
-		DEBUG(0,("protocol negotiation failed\n"));
+		DEBUG(0,(_("protocol negotiation failed\n")));
 		cli_shutdown(c);
 		free(c);
 		return NULL;
 	}
 
 	if (!got_pass) {
-		char *pass = getpass("Password: ");
+		char *pass = getpass(_("Password: "));
 		if (pass) {
 			pstrcpy(password, pass);
 		}
@@ -1961,12 +1964,12 @@
 		/* if a password was not supplied then try again with a null username */
 		if (password[0] || !username[0] || 
 		    !cli_session_setup(c, "", "", 0, "", 0, workgroup)) { 
-			DEBUG(0,("session setup failed: %s\n", cli_errstr(c)));
+			DEBUG(0,(_("session setup failed: %s\n"), cli_errstr(c)));
 			cli_shutdown(c);
 			free(c);
 			return NULL;
 		}
-		DEBUG(0,("Anonymous login successful\n"));
+		DEBUG(0,(_("Anonymous login successful\n")));
 	}
 
 	/*
@@ -1978,20 +1981,20 @@
 	 */
 
 	if (*c->server_domain || *c->server_os || *c->server_type)
-		DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n",
+		DEBUG(1,(_("Domain=[%s] OS=[%s] Server=[%s]\n"),
 			c->server_domain,c->server_os,c->server_type));
 	
-	DEBUG(4,(" session setup ok\n"));
+	DEBUG(4,(_(" session setup ok\n")));
 
 	if (!cli_send_tconX(c, sharename, "?????",
 			    password, strlen(password)+1)) {
-		DEBUG(0,("tree connect failed: %s\n", cli_errstr(c)));
+		DEBUG(0,(_("tree connect failed: %s\n"), cli_errstr(c)));
 		cli_shutdown(c);
 		free(c);
 		return NULL;
 	}
 
-	DEBUG(4,(" tconx ok\n"));
+	DEBUG(4,(_(" tconx ok\n")));
 
 	return c;
 }
@@ -2024,33 +2027,33 @@
 ****************************************************************************/
 static void usage(char *pname)
 {
-  DEBUG(0,("Usage: %s service <password> [options]", pname));
+  DEBUG(0,(_("Usage: %s service <password> [options]"), pname));
 
-  DEBUG(0,("\nVersion %s\n",VERSION));
-  DEBUG(0,("\t-s smb.conf           pathname to smb.conf file\n"));
-  DEBUG(0,("\t-O socket_options     socket options to use\n"));
-  DEBUG(0,("\t-R name resolve order use these name resolution services only\n"));
-  DEBUG(0,("\t-M host               send a winpopup message to the host\n"));
-  DEBUG(0,("\t-i scope              use this NetBIOS scope\n"));
-  DEBUG(0,("\t-N                    don't ask for a password\n"));
-  DEBUG(0,("\t-n netbios name.      Use this name as my netbios name\n"));
-  DEBUG(0,("\t-d debuglevel         set the debuglevel\n"));
-  DEBUG(0,("\t-P                    connect to service as a printer\n"));
-  DEBUG(0,("\t-p port               connect to the specified port\n"));
-  DEBUG(0,("\t-l log basename.      Basename for log/debug files\n"));
-  DEBUG(0,("\t-h                    Print this help message.\n"));
-  DEBUG(0,("\t-I dest IP            use this IP to connect to\n"));
-  DEBUG(0,("\t-E                    write messages to stderr instead of stdout\n"));
-  DEBUG(0,("\t-U username           set the network username\n"));
-  DEBUG(0,("\t-L host               get a list of shares available on a host\n"));
-  DEBUG(0,("\t-t terminal code      terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"));
-  DEBUG(0,("\t-m max protocol       set the max protocol level\n"));
-  DEBUG(0,("\t-A filename           get the credentials from a file\n"));
-  DEBUG(0,("\t-W workgroup          set the workgroup name\n"));
-  DEBUG(0,("\t-T<c|x>IXFqgbNan      command line tar\n"));
-  DEBUG(0,("\t-D directory          start from directory\n"));
-  DEBUG(0,("\t-c command string     execute semicolon separated commands\n"));
-  DEBUG(0,("\t-b xmit/send buffer   changes the transmit/send buffer (default: 65520)\n"));
+  DEBUG(0,(_("\nVersion %s\n"),VERSION));
+  DEBUG(0,(_("\t-s smb.conf           pathname to smb.conf file\n")));
+  DEBUG(0,(_("\t-O socket_options     socket options to use\n")));
+  DEBUG(0,(_("\t-R name resolve order use these name resolution services only\n")));
+  DEBUG(0,(_("\t-M host               send a winpopup message to the host\n")));
+  DEBUG(0,(_("\t-i scope              use this NetBIOS scope\n")));
+  DEBUG(0,(_("\t-N                    don't ask for a password\n")));
+  DEBUG(0,(_("\t-n netbios name       Use this name as my netbios name\n")));
+  DEBUG(0,(_("\t-d debuglevel         set the debuglevel\n")));
+  DEBUG(0,(_("\t-P                    connect to service as a printer\n")));
+  DEBUG(0,(_("\t-p port               connect to the specified port\n")));
+  DEBUG(0,(_("\t-l log basename       Basename for log/debug files\n")));
+  DEBUG(0,(_("\t-h                    Print this help message.\n")));
+  DEBUG(0,(_("\t-I dest IP            use this IP to connect to\n")));
+  DEBUG(0,(_("\t-E                    write messages to stderr instead of stdout\n")));
+  DEBUG(0,(_("\t-U username           set the network username\n")));
+  DEBUG(0,(_("\t-L host               get a list of shares available on a host\n")));
+  DEBUG(0,(_("\t-t terminal code      terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n")));
+  DEBUG(0,(_("\t-m max protocol       set the max protocol level\n")));
+  DEBUG(0,(_("\t-A filename           get the credentials from a file\n")));
+  DEBUG(0,(_("\t-W workgroup          set the workgroup name\n")));
+  DEBUG(0,(_("\t-T<c|x>IXFqgbNan      command line tar\n")));
+  DEBUG(0,(_("\t-D directory          start from directory\n")));
+  DEBUG(0,(_("\t-c command string     execute semicolon separated commands\n")));
+  DEBUG(0,(_("\t-b xmit/send buffer   changes the transmit/send buffer (default: 65520)\n")));
   DEBUG(0,("\n"));
 }
 
@@ -2076,7 +2079,7 @@
 		fd = sys_open(p, O_RDONLY, 0);
 		pstrcpy(spec, p);
 		if (fd < 0) {
-			fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
+			fprintf(stderr, _("Error opening PASSWD_FILE %s: %s\n"),
 				spec, strerror(errno));
 			exit(1);
 		}
@@ -2097,13 +2100,13 @@
 				p = NULL; /* then force the loop condition to become false */
 				break;
 			} else {
-				fprintf(stderr, "Error reading password from file %s: %s\n",
-					spec, "empty password\n");
+				fprintf(stderr, _("Error reading password from file %s: %s\n"),
+					spec, _("empty password\n"));
 				exit(1);
 			}
 			
 		default:
-			fprintf(stderr, "Error reading password from file %s: %s\n",
+			fprintf(stderr, _("Error reading password from file %s: %s\n"),
 				spec, strerror(errno));
 			exit(1);
 		}
@@ -2171,12 +2174,12 @@
 	if (have_ip) ip = dest_ip;
 
 	if (!(cli=cli_initialise(NULL)) || !cli_connect(cli, desthost, &ip)) {
-		DEBUG(0,("Connection to %s failed\n", desthost));
+		DEBUG(0,(_("Connection to %s failed\n"), desthost));
 		return 1;
 	}
 
 	if (!cli_session_request(cli, &calling, &called)) {
-		DEBUG(0,("session request failed\n"));
+	  DEBUG(0,(_("session request failed\n")));
 		cli_shutdown(cli);
 		return 1;
 	}
@@ -2220,6 +2223,14 @@
 
 	DEBUGLEVEL = 2;
 
+	setlocale(LC_MESSAGES, "");
+        bindtextdomain(I18N_PACKAGE,I18N_LOCALEDIR);
+        textdomain(I18N_PACKAGE);
+	printf(I18N_PACKAGE);
+	printf("\n");
+	printf(I18N_LOCALEDIR);
+	printf("\n");
+
 #ifdef HAVE_LIBREADLINE
 	/* Allow conditional parsing of the ~/.inputrc file. */
 	rl_readline_name = "smbclient";
@@ -2256,7 +2267,7 @@
 	in_client = True;   /* Make sure that we tell lp_load we are */
 
 	if (!lp_load(servicesf,True,False,False)) {
-		fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
+		fprintf(stderr, _("Can't load %s - run testparm to debug it\n"), servicesf);
 	}
 	
 	codepage_initialise(lp_client_code_page());
@@ -2314,17 +2325,9 @@
   
 	if (*argv[1] != '-') {
 		pstrcpy(service,argv[1]);  
-		/* Convert any '/' characters in the service name to '\' characters */
-		string_replace( service, '/','\\');
 		argc--;
 		argv++;
 		
-		if (count_chars(service,'\\') < 3) {
-			usage(pname);
-			printf("\n%s: Not enough '\\' characters in service\n",service);
-			exit(1);
-		}
-
 		if (argc > 1 && (*argv[1] != '-')) {
 			got_pass = True;
 			pstrcpy(password,argv[1]);  
@@ -2417,7 +2420,7 @@
 	                        if ((auth=sys_fopen(optarg, "r")) == NULL)
 				{
 					/* fail if we can't open the credentials file */
-					DEBUG(0,("ERROR: Unable to open credentials file!\n"));
+					DEBUG(0,(_("ERROR: Unable to open credentials file!\n")));
 					exit (-1);
 				}
                                 
@@ -2507,12 +2510,24 @@
 	if (*term_code)
 		interpret_coding_system(term_code);
 
+	/* Convert any '/' characters in the service name to '\' characters */
+	unix_to_dos(service, True);
+	unix_to_dos(desthost, True);
+
+	string_replace( service, '/','\\');
+	
+	if (count_chars(service,'\\') < 3) {
+	    usage(pname);
+	    printf(_("\n%s: Not enough '\\' characters in service\n"),service);
+	    exit(1);
+	}
+
 	if (!tar_type && !*query_host && !*service && !message) {
 		usage(pname);
 		exit(1);
 	}
 
-	DEBUG( 3, ( "Client started (version %s).\n", VERSION ) );
+	DEBUG( 3, ( _("Client started (version %s).\n"), VERSION ) );
 
 	if (tar_type) {
 		return do_tar_op(base_directory);


More information about the samba-technical mailing list