Package: wmtime
Version: 1.0b3-2
Severity: normal
Tags: upstream patch l10n
Hi,
the package wmtime claims that it supports localization. Looking into the code,
it seems more like date customization.
When claiming "localization", it should work as such - respecting LANG, LC_ALL,
etc. environment variables and use locales for the day and month abbreviations.
Please see my patch which adds such support.
Regards,
Milan Cermak
-- System Information:
Debian Release: 6.0.4
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.37.6 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=cs_CZ.UTF-8, LC_CTYPE=cs_CZ.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages wmtime depends on:
ii libc6 2.11.3-2 Embedded GNU C Library: Shared lib
ii libx11-6 2:1.3.3-4 X11 client-side library
ii libxext6 2:1.1.2-1 X11 miscellaneous extension librar
ii libxpm4 1:3.5.8-1 X11 pixmap library
wmtime recommends no packages.
wmtime suggests no packages.
-- no debconf information
diff -Naur wmtime-1.0b2.orig/wmtime/wmtime.c wmtime-1.0b3.orig/wmtime/wmtime.c
--- wmtime-1.0b2.orig/wmtime/wmtime.c 2011-10-14 14:01:32.696870000 +0200
+++ wmtime-1.0b3.orig/wmtime/wmtime.c 2012-02-29 21:16:33.022405000 +0100
@@ -65,6 +65,10 @@
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
+#include <locale.h>
+#include <langinfo.h>
+#include <iconv.h>
+#include <ctype.h>
#include <sys/wait.h>
#include <sys/param.h>
@@ -148,7 +152,10 @@
}
}
}
- get_lang();
+
+ if (setlocale(LC_ALL, "") != NULL)
+ get_lang();
+
wmtime_routine(argc, argv);
return 0;
}
@@ -156,26 +163,44 @@
/************/
/* get_lang */
/************/
-void get_lang(){
- FILE *fp;
- int i;
- const int line_size = 5;
- char line[line_size];
-
- fp=fopen("language","r");
- if (fp) {
- /* Grab the days of the week */
- for (i=0;i<7;i++){
- fgets(line, line_size, fp);
- strncpy(day_of_week[i], line, 2);
- };
- /* Grab the names of the months */
- for (i=0;i<12;i++){
- fgets(line, line_size, fp);
- strncpy(mon_of_year[i], line, 3);
- };
- fclose(fp);
- };
+void get_lang(void)
+{
+ char langbuf[10], outbuf[10];
+ char *inp, *outp;
+ iconv_t icd;
+ int i, ret;
+ size_t insize, outsize;
+
+ icd = iconv_open("ASCII//TRANSLIT", nl_langinfo(CODESET));
+ if (icd < 0)
+ return;
+
+ for (i = 0; i < 7; i++) {
+ strncpy(langbuf, nl_langinfo(ABDAY_1 + i), 10);
+ insize = outsize = 10;
+ inp = langbuf;
+ outp = outbuf;
+ do {
+ ret = iconv(icd, &inp, &insize, &outp, &outsize);
+ } while (outsize > 0 && ret > 0);
+ for (outp = outbuf, outsize = 0; *outp != 0 && outsize < 2;
+ outp++, outsize++)
+ day_of_week[i][outsize] = toupper(*outp);
+ }
+ for (i = 0; i < 12; i++) {
+ strncpy(langbuf, nl_langinfo(ABMON_1 + i), 10);
+ insize = outsize = 10;
+ inp = langbuf;
+ outp = outbuf;
+ do {
+ ret = iconv(icd, &inp, &insize, &outp, &outsize);
+ } while (outsize > 0 && ret > 0);
+ for (outp = outbuf, outsize = 0; *outp != 0 && outsize < 3;
+ outp++, outsize++)
+ mon_of_year[i][outsize] = toupper(*outp);
+ }
+
+ iconv_close(icd);
}
/*******************************************************************************\