Based on a similar patch for wmitime [1].

[1] 
http://repo.or.cz/w/dockapps.git/commitdiff/cc801880a5be8902af715ff1722981a4bc35bf6d
---
 wmtime/INSTALL  |  6 +++---
 wmtime/wmtime.1 |  6 +++++-
 wmtime/wmtime.c | 17 +++++++++++++++--
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/wmtime/INSTALL b/wmtime/INSTALL
index 813a6e0..cff76a8 100644
--- a/wmtime/INSTALL
+++ b/wmtime/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/wmtime.1 b/wmtime/wmtime.1
index 8b51e57..9fb1a89 100644
--- a/wmtime/wmtime.1
+++ b/wmtime/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/wmtime.c b/wmtime/wmtime.c
index 2bb9c5c..b23d065 100644
--- a/wmtime/wmtime.c
+++ b/wmtime/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");
 }
-- 
2.1.0


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to