All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/23] mount.nfs: Support double-wide characters in printed strings
@ 2007-07-28 21:49 Chuck Lever
  2007-07-29  7:39 ` Neil Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2007-07-28 21:49 UTC (permalink / raw)
  To: neilb; +Cc: nfs

NLS changes missed a spot or two.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/mount/error.c     |   19 ++++++++++---------
 utils/mount/mount.c     |   32 ++++++++++++++++----------------
 utils/mount/nfs4mount.c |   10 +++++-----
 utils/mount/nfsmount.c  |    7 +++----
 utils/mount/nfsumount.c |   18 +++++++++---------
 5 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/utils/mount/error.c b/utils/mount/error.c
index 62f6850..74f8354 100644
--- a/utils/mount/error.c
+++ b/utils/mount/error.c
@@ -67,9 +67,10 @@ static int rpc_strerror(int spos)
 		tmp = &errbuf[spos];
 		if (cf_stat == RPC_SYSTEMERROR)
 			pos = snprintf(tmp, (erreob - tmp),
-				"System Error: %s", strerror(cf_errno));
+				_("System Error: %s"), strerror(cf_errno));
 		else
-			pos = snprintf(tmp, (erreob - tmp), "RPC Error:%s", estr);
+			pos = snprintf(tmp, (erreob - tmp),
+					_("RPC Error: %s"), estr);
 	}
 	return pos;
 }
@@ -83,21 +84,21 @@ void mount_errors(char *server, int will_retry, int bg)
 	tmp = &errbuf[pos];
 	if (bg)
 		pos = snprintf(tmp, (erreob - tmp),
-			"mount to NFS server '%s' failed: ", server);
+			_("mount to NFS server '%s' failed: "), server);
 	else
 		pos = snprintf(tmp, (erreob - tmp),
-			"mount: mount to NFS server '%s' failed: ", server);
+			_("mount: mount to NFS server '%s' failed: "), server);
 
 	tmp = &errbuf[pos];
 	if (rpc_createerr.cf_stat == RPC_TIMEDOUT) {
-		pos = snprintf(tmp, (erreob - tmp), "timed out %s",
-			will_retry ? "(retrying)" : "(giving up)");
+		pos = snprintf(tmp, (erreob - tmp), _("timed out %s"),
+			will_retry ? _("(retrying)") : _("(giving up)"));
 	} else {
 		pos += rpc_strerror(pos);
 		tmp = &errbuf[pos];
 		if (bg) {
-			pos = snprintf(tmp, (erreob - tmp), " %s",
-				will_retry ? "(retrying)" : "(giving up)");
+			pos = snprintf(tmp, (erreob - tmp), _(" %s"),
+				will_retry ? _("(retrying)") : _("(giving up)"));
 		}
 	}
 	if (bg) {
@@ -105,7 +106,7 @@ void mount_errors(char *server, int will_retry, int bg)
 			openlog("mount", LOG_CONS|LOG_PID, LOG_AUTH);
 		syslog(LOG_ERR, "%s.", errbuf);
 	} else
-		fprintf(stderr, "%s.\n", errbuf);
+		fprintf(stderr, _("%s.\n"), errbuf);
 }
 
 void mount_error(const char *spec, const char *mount_point, int error)
diff --git a/utils/mount/mount.c b/utils/mount/mount.c
index 7a4912e..9503187 100644
--- a/utils/mount/mount.c
+++ b/utils/mount/mount.c
@@ -176,12 +176,12 @@ static void discover_nfs_mount_data_version(void)
 static void print_one(char *spec, char *node, char *type, char *opts)
 {
 	if (verbose) {
-		printf("%s on %s type %s", spec, node, type);
+		printf(_("%s on %s type %s"), spec, node, type);
 
 		if (opts != NULL)
-			printf(" (%s)", opts);
+			printf(_(" (%s)"), opts);
 
-		printf("\n");
+		printf(_("\n"));
 	}
 }
 
@@ -269,18 +269,18 @@ fail_unlock:
 
 void mount_usage()
 {
-	printf("usage: %s remotetarget dir [-rvVwfnh] [-o nfsoptions]\n",
+	printf(_("usage: %s remotetarget dir [-rvVwfnh] [-o nfsoptions]\n"),
 		progname);
-	printf("options:\n");
-	printf("\t-r\t\tMount file system readonly\n");
-	printf("\t-v\t\tVerbose\n");
-	printf("\t-V\t\tPrint version\n");
-	printf("\t-w\t\tMount file system read-write\n");
-	printf("\t-f\t\tFake mount, do not actually mount\n");
-	printf("\t-n\t\tDo not update /etc/mtab\n");
-	printf("\t-s\t\tTolerate sloppy mount options rather than failing.\n");
-	printf("\t-h\t\tPrint this help\n");
-	printf("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n");
+	printf(_("options:\n"));
+	printf(_("\t-r\t\tMount file system readonly\n"));
+	printf(_("\t-v\t\tVerbose\n"));
+	printf(_("\t-V\t\tPrint version\n"));
+	printf(_("\t-w\t\tMount file system read-write\n"));
+	printf(_("\t-f\t\tFake mount, do not actually mount\n"));
+	printf(_("\t-n\t\tDo not update /etc/mtab\n"));
+	printf(_("\t-s\t\tTolerate sloppy mount options rather than failing.\n"));
+	printf(_("\t-h\t\tPrint this help\n"));
+	printf(_("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n"));
 }
 
 static void parse_opt(const char *opt, int *mask, char *extra_opts, int len)
@@ -384,7 +384,7 @@ int main(int argc, char *argv[])
 
 	if (argv[1] && argv[1][0] == '-') {
 		if(argv[1][1] == 'V')
-			printf("%s ("PACKAGE_STRING")\n", progname);
+			printf(_("%s ("PACKAGE_STRING")\n"), progname);
 		else
 			mount_usage();
 		exit(0);
@@ -409,7 +409,7 @@ int main(int argc, char *argv[])
 			++verbose;
 			break;
 		case 'V':
-			printf("%s: ("PACKAGE_STRING")\n", progname);
+			printf(_("%s: ("PACKAGE_STRING")\n"), progname);
 			return 0;
 		case 'w':
 			flags &= ~MS_RDONLY;
diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
index 26a6896..bd20864 100644
--- a/utils/mount/nfs4mount.c
+++ b/utils/mount/nfs4mount.c
@@ -160,7 +160,7 @@ static int get_my_ipv4addr(char *ip_addr, int len)
 	}
 	if (fill_ipv4_sockaddr(myname, &myaddr))
 		return -1;
-	snprintf(ip_addr, len, "%s", inet_ntoa(myaddr.sin_addr));
+	snprintf(ip_addr, len, _("%s"), inet_ntoa(myaddr.sin_addr));
 	ip_addr[len-1] = '\0';
 	return 0;
 }
@@ -212,8 +212,8 @@ int nfs4mount(const char *spec, const char *node, int flags,
 				progname);
 		goto fail;
 	}
-	snprintf(new_opts, sizeof(new_opts), "%s%saddr=%s",
-		 old_opts, *old_opts ? "," : "", s);
+	snprintf(new_opts, sizeof(new_opts), _("%s%saddr=%s"),
+		 old_opts, *old_opts ? _(",") : _(""), s);
 	*extra_opts = xstrdup(new_opts);
 
 	/* Set default options.
@@ -322,7 +322,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
 				unshared = !val;
 			else if (!sloppy) {
 				printf(_("unknown nfs mount option: "
-					 "%s%s\n"), val ? "" : "no", opt);
+					 "%s%s\n"), val ? _("") : _("no"), opt);
 				goto fail;
 			}
 		}
@@ -414,7 +414,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
 			if (!ip_addr_in_opts &&
 			    client_addr.sin_family != 0 &&
 			    client_addr.sin_addr.s_addr != 0) {
-				snprintf(ip_addr, sizeof(ip_addr), "%s",
+				snprintf(ip_addr, sizeof(ip_addr), _("%s"),
 					 inet_ntoa(client_addr.sin_addr));
 				data.client_addr.len = strlen(ip_addr);
 			}
diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c
index 6949b50..ac8d161 100644
--- a/utils/mount/nfsmount.c
+++ b/utils/mount/nfsmount.c
@@ -192,7 +192,6 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 		if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) {
 			int val = atoi(opteq + 1);	
 			*opteq = '\0';
-/* printf("opt=%s\n", opt); */
 			if (!strcmp(opt, "rsize"))
 				data->rsize = val;
 			else if (!strcmp(opt, "wsize"))
@@ -249,7 +248,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 				continue;
 			else
 				goto bad_parameter;
-			sprintf(cbuf, "%s=%s,", opt, opteq+1);
+			sprintf(cbuf, _("%s=%s,"), opt, opteq+1);
 		} else if (opteq) {
 			*opteq = '\0';
 			if (!strcmp(opt, "proto")) {
@@ -332,7 +331,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 				continue;
 			else
 				goto bad_parameter;
-			sprintf(cbuf, "%s=%s,", opt, opteq+1);
+			sprintf(cbuf, _("%s=%s,"), opt, opteq+1);
 		} else {
 			int val = 1;
 			if (!strncmp(opt, "no", 2)) {
@@ -431,7 +430,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 					 "%s%s\n"), val ? "" : "no", opt);
 				goto out_bad;
 			}
-			sprintf(cbuf, val ? "%s,":"no%s,", opt);
+			sprintf(cbuf, val ? _("%s,") : _("no%s,"), opt);
 		}
 		len += strlen(cbuf);
 		if (len >= opt_size) {
diff --git a/utils/mount/nfsumount.c b/utils/mount/nfsumount.c
index 303b485..dbfb85b 100644
--- a/utils/mount/nfsumount.c
+++ b/utils/mount/nfsumount.c
@@ -141,7 +141,7 @@ int del_mtab(const char *spec, const char *node)
         if (res >= 0) {
                 /* Umount succeeded */
                 if (verbose)
-                        printf (_("%s umounted\n"), spec ? spec : node);
+                        printf(_("%s umounted\n"), spec ? spec : node);
         }
 
  writemtab:
@@ -238,13 +238,13 @@ static struct option umount_longopts[] =
 
 void umount_usage()
 {
-	printf("usage: %s dir [-fvnrlh]\n", progname);
-	printf("options:\n\t-f\t\tforce unmount\n");
-	printf("\t-v\t\tverbose\n");
-	printf("\t-n\t\tDo not update /etc/mtab\n");
-	printf("\t-r\t\tremount\n");
-	printf("\t-l\t\tlazy unmount\n");
-	printf("\t-h\t\tprint this help\n\n");
+	printf(_("usage: %s dir [-fvnrlh]\n"), progname);
+	printf(_("options:\n\t-f\t\tforce unmount\n"));
+	printf(_("\t-v\tverbose\n"));
+	printf(_("\t-n\tDo not update /etc/mtab\n"));
+	printf(_("\t-r\tremount\n"));
+	printf(_("\t-l\tlazy unmount\n"));
+	printf(_("\t-h\tprint this help\n\n"));
 }
 
 int nfsumount(int argc, char *argv[])
@@ -303,7 +303,7 @@ int nfsumount(int argc, char *argv[])
 
 	if (mc && strcmp(mc->m.mnt_type, "nfs") != 0 &&
 	    strcmp(mc->m.mnt_type, "nfs4") != 0) {
-		nfs_error(_("%s: %s on %s it not an nfs filesystem"),
+		nfs_error(_("%s: %s on %s is not an nfs filesystem"),
 				progname, mc->m.mnt_fsname, mc->m.mnt_dir);
 		return EX_USAGE;
 	}


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 01/23] mount.nfs: Support double-wide characters in printed strings
  2007-07-28 21:49 [PATCH 01/23] mount.nfs: Support double-wide characters in printed strings Chuck Lever
@ 2007-07-29  7:39 ` Neil Brown
  2007-07-29 20:05   ` Chuck Lever
  0 siblings, 1 reply; 4+ messages in thread
From: Neil Brown @ 2007-07-29  7:39 UTC (permalink / raw)
  To: Chuck Lever; +Cc: nfs

On Saturday July 28, chuck.lever@oracle.com wrote:
> NLS changes missed a spot or two.
> 
> @@ -105,7 +106,7 @@ void mount_errors(char *server, int will_retry, int bg)
>  			openlog("mount", LOG_CONS|LOG_PID, LOG_AUTH);
>  		syslog(LOG_ERR, "%s.", errbuf);
>  	} else
> -		fprintf(stderr, "%s.\n", errbuf);
> +		fprintf(stderr, _("%s.\n"), errbuf);
>  }

Do we really want NLS support for putting a full stop at the end of a
line?
>  		if (opts != NULL)
> -			printf(" (%s)", opts);
> +			printf(_(" (%s)"), opts);

and putting something in parentheses

>  
> -		printf("\n");
> +		printf(_("\n"));

and for a single newline?

> index 26a6896..bd20864 100644
> --- a/utils/mount/nfs4mount.c
> +++ b/utils/mount/nfs4mount.c
> @@ -160,7 +160,7 @@ static int get_my_ipv4addr(char *ip_addr, int len)
>  	}
>  	if (fill_ipv4_sockaddr(myname, &myaddr))
>  		return -1;
> -	snprintf(ip_addr, len, "%s", inet_ntoa(myaddr.sin_addr));
> +	snprintf(ip_addr, len, _("%s"), inet_ntoa(myaddr.sin_addr));

Why this change?  Does it achieve anything?


>  	}
> -	snprintf(new_opts, sizeof(new_opts), "%s%saddr=%s",
> -		 old_opts, *old_opts ? "," : "", s);
> +	snprintf(new_opts, sizeof(new_opts), _("%s%saddr=%s"),
> +		 old_opts, *old_opts ? _(",") : _(""), s);
>  	*extra_opts = xstrdup(new_opts);

????


> -				snprintf(ip_addr, sizeof(ip_addr), "%s",
> +				snprintf(ip_addr, sizeof(ip_addr), _("%s"),

???


Maybe I'm mistaken, but I thought _(xxx) was just to allow
localisations to provide different translations of xxx.  When it is
something like punctuation - particularly an end-of-line character - 
I don't think I see the point.
Also you seem to have added it when building up option lists, and I
don't think it makes sense to translate those.

So please either show me the error of my thinking, or stick to adding
_() to translatable strings.

Much of this patch is good and wanted, I'm not sure about the whole.
Similarly for patch 2.

I only got 12 of the 23 patches??

NeilBrown

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 01/23] mount.nfs: Support double-wide characters in printed strings
  2007-07-29  7:39 ` Neil Brown
@ 2007-07-29 20:05   ` Chuck Lever
  2007-07-30  5:30     ` Neil Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2007-07-29 20:05 UTC (permalink / raw)
  To: Neil Brown; +Cc: nfs

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

> So please either show me the error of my thinking, or stick to adding
> _() to translatable strings.
> 
> Much of this patch is good and wanted, I'm not sure about the whole.
> Similarly for patch 2.

Yeah, the options stuff was a mistake which I thought I had avoided. 
Will fix all this up and post a fresh patch set.

But my impression was a double-byte "." is not the same as a single-byte 
".".  I'm not an expert, and would be happy if someone (like a 
distributor) had an internationalization expert they could loan us.

> I only got 12 of the 23 patches??

The list didn't see half of these either.  Will investigate.  I probably 
shut down my laptop before it was done relaying the patches.

[-- Attachment #2: chuck.lever.vcf --]
[-- Type: text/x-vcard, Size: 290 bytes --]

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard


[-- Attachment #3: Type: text/plain, Size: 315 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 140 bytes --]

_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 01/23] mount.nfs: Support double-wide characters in printed strings
  2007-07-29 20:05   ` Chuck Lever
@ 2007-07-30  5:30     ` Neil Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Brown @ 2007-07-30  5:30 UTC (permalink / raw)
  To: chuck.lever; +Cc: nfs

On Sunday July 29, chuck.lever@oracle.com wrote:
> > So please either show me the error of my thinking, or stick to adding
> > _() to translatable strings.
> > 
> > Much of this patch is good and wanted, I'm not sure about the whole.
> > Similarly for patch 2.
> 
> Yeah, the options stuff was a mistake which I thought I had avoided. 
> Will fix all this up and post a fresh patch set.
> 
> But my impression was a double-byte "." is not the same as a single-byte 
> ".".  I'm not an expert, and would be happy if someone (like a 
> distributor) had an internationalization expert they could loan us.

I think you are confusing two things (that are easily confused).
With some loss of generality, I will call them unicode and utf, the
Unicode Transport Format(??)

Unicode uses wide characters, 16bits each. 'wchar'.  The unicode '.'
is different from the ASCII '.' simply because they have different
numbers of bits (though I think the low order bits are the same, and
the high order bits in unicode are all zero).

Code which wants to process international character sets a character
at a time needs handle the text as wchars, typically arrays of wchars.
They are two bytes each.

However code that just wants to work with known strings and doesn't
really care about the content can use UTF instead.  UTF encodes a
Unicode string using 1, 2 or 3 bytes for each character.  All 7-bit
ASCII symbols have their standard 1byte encoding.  Other symbols are 2
or 3 bytes.

So if you just want to print a message, you can use an array of
'char' and store any international text in there.  No need to
explicitly use wchar.

If you want to use a string value that can be localised, you use
   _("string")
and the NLS tools will allow that to be swapped for a localised
version, possibly using UTF to represent unicode characters, at
runtime.

So you only need _(xxx) for translatable strings.  Things like " " (a
space), "\n" definitely don't need translation.  Things like ":" could
conceivably benefit from translation, but I doubt that it really makes
sense to translate them in isolation.  Places where punctuation has a
strong meaning like in dates, times, currency etc have separate
functionality for doing localisation (strftime, strfmon) so for normal
usage, I don't think it is appropriate to translate individual
punctuation characters.

Does that make sense?

> 
> > I only got 12 of the 23 patches??
> 
> The list didn't see half of these either.  Will investigate.  I probably 
> shut down my laptop before it was done relaying the patches.

Grin...
I seem to have them now.  Thanks.

NeilBrown

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-30  5:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-28 21:49 [PATCH 01/23] mount.nfs: Support double-wide characters in printed strings Chuck Lever
2007-07-29  7:39 ` Neil Brown
2007-07-29 20:05   ` Chuck Lever
2007-07-30  5:30     ` Neil Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.