Hi,

This can affect invocations of `ls' that don't include an explicit
`--time-style=locale', as well, since that is now the default (in
absence of a TIME_STYLE environment variable).

The only case I can see in the head revision of `ls.c' where the
default English time-style is used is when there is no `hard locale'
in effect for time (LC_TIME=C or POSIX).

In case it might be desirable to have the time-style default to N_("%b
%e  %Y") and  N_("%b %e %H:%M") (the `defaults') rather than
'posix-long-iso' ("%Y-%m-%d %H:%M" in all cases) for locales that
begin with 'en_', I've included a small patch that provides this
behavior.

----
$ LC_ALL=zh_CN.UTF-8 src/ls -l TODO
-rw-r--r-- 1 bo bo 6908 2008-03-31 21:09 TODO

$ LC_ALL=en_US.UTF-8 src/ls -l TODO
-rw-r--r-- 1 bo bo 6908 Mar 31 21:09 TODO

$ LC_ALL=C src/ls -l TODO
-rw-r--r-- 1 bo bo 6908 Mar 31 21:09 TODO
----

Thanks,

Bo
From d239d2fffcee499da5f3c5b4ddacc9caa258f3b0 Mon Sep 17 00:00:00 2001
From: Bo Borgerson <[EMAIL PROTECTED]>
Date: Sun, 6 Apr 2008 11:47:28 -0400
Subject: [PATCH] Use default English time-formats for `en_*' locales

src/ls.c: (decode_switches) only goto case_long_iso_time_style
from `locale' time-format setting when the untranslated locale
is not an `en_*' locale.

Signed-off-by: Bo Borgerson <[EMAIL PROTECTED]>
---
 src/ls.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/ls.c b/src/ls.c
index e029fe0..e5fbd0d 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1924,16 +1924,30 @@ decode_switches (int argc, char **argv)
 	    if (hard_locale (LC_TIME))
 	      {
 		/* Ensure that the locale has translations for both
-		   formats.  If not, fall back on long-iso format.  */
+		   formats.  If not, fall back on either the default
+		   format for en_* locales or on long-iso format for
+		   non-en_* locales.  */
 		int i;
+		char *full_cutover[2] = {NULL, NULL};
+		char const *lc_time = setlocale (LC_TIME, NULL);
+		char const *lc_en_prefix = "en_";
+
 		for (i = 0; i < 2; i++)
 		  {
 		    char const *locale_format =
 		      dcgettext (NULL, long_time_format[i], LC_TIME);
 		    if (locale_format == long_time_format[i])
-		      goto case_long_iso_time_style;
-		    long_time_format[i] = locale_format;
+		      break;
+		    full_cutover[i] = (char *) locale_format;
+		  }
+		if (full_cutover[0] && full_cutover[1])
+		  {
+		    long_time_format[0] = full_cutover[0];
+		    long_time_format[1] = full_cutover[1];
 		  }
+		else if (strncmp (lc_time, lc_en_prefix,
+		    strlen (lc_en_prefix)))
+		  goto case_long_iso_time_style;
 	      }
 	  }
     }
-- 
1.5.2.5

_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to