[Pkg-wmaker-commits] [wmtime] 17/101: wmtime: Add -l option to specify locale.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:59:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmtime.

commit 499358c79e5abd9de17cd73dccddfc45cafe0f6e
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Sat Jan 3 16:16:19 2015 -0600

    wmtime: Add -l option to specify locale.
    
    Based on a similar patch for wmitime [1].
    
    [1] http://repo.or.cz/w/dockapps.git/commitdiff/cc801880a5be8902af715ff1722981a4bc35bf6d
---
 INSTALL  |  6 +++---
 wmtime.1 |  6 +++++-
 wmtime.c | 17 +++++++++++++++--
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/INSTALL b/INSTALL
index 813a6e0..cff76a8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -16,10 +16,10 @@ Installation
     use Latin alphabet characters, then WMTime defaults to
     US/English.
 
-    You may change this behavior by setting the LANG
-    environment variable, e.g.,
+    You may change this behavior by using the '-l' command line
+    option, e.g.,
 
-    % LANG=es_MX.UTF-8 wmtime
+    % wmtime -l es_MX.utf8
 
 Be sure to read the HINTS and TODO files too!
 
diff --git a/wmtime.1 b/wmtime.1
index 8b51e57..9fb1a89 100644
--- a/wmtime.1
+++ b/wmtime.1
@@ -17,7 +17,7 @@
 .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 .\" USA.
 .\"
-.TH WMTIME 1 "October 2013" "WMTIME 1.1"
+.TH WMTIME 1 "January 2015" "WMTIME 1.1"
 
 .SH NAME
 wmtime \- Window Maker dockapp that displays the time and date
@@ -70,6 +70,10 @@ This option specifies the preferred position of clock; see
 Disables the second hand.
 
 .TP
+.BI \-l \ locale
+Specify locale.
+
+.TP
 .B \-h
 Show help information.
 
diff --git a/wmtime.c b/wmtime.c
index 2bb9c5c..b23d065 100644
--- a/wmtime.c
+++ b/wmtime.c
@@ -114,6 +114,9 @@ int main(int argc, char *argv[]) {
 
 	int		i;
 	char    *name = argv[0];
+	char locale[256];
+
+	locale[0] = 0;
 
 	for (i=1; i<argc; i++) {
 		char *arg = argv[i];
@@ -146,6 +149,12 @@ int main(int argc, char *argv[]) {
 			case 'v' :
 				printversion();
 				return 0;
+			case 'l':
+				if (argc > i+1) {
+					strcpy(locale, argv[i+1]);
+					i++;
+				}
+				break;
 			default:
 				usage(name);
 				return 1;
@@ -153,8 +162,11 @@ int main(int argc, char *argv[]) {
 		}
 	}
 
-	if (setlocale(LC_ALL, "") != NULL)
-		get_lang();
+	if (setlocale(LC_ALL, locale) == NULL)
+		fprintf(stderr,
+			"warning: locale '%s' not recognized; defaulting to '%s'.",
+			locale, setlocale(LC_ALL, NULL));
+	get_lang();
 
 	wmtime_routine(argc, argv);
 	return 0;
@@ -675,6 +687,7 @@ void usage(char *name) {
 	printf("  -display DISPLAY     contact the DISPLAY X server\n");
 	printf("  -geometry GEOMETRY   position the clock at GEOMETRY\n");
 	printf("  -n, -noseconds       disables the second hand\n");
+	printf("  -l LOCALE            set locale to LOCALE\n");
 	printf("  -h                   display this help and exit\n");
 	printf("  -v                   output version information and exit\n");
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmtime.git



More information about the Pkg-wmaker-commits mailing list