Hello Marcelo,
with help from my brother I've attached a working run time locale
detection now. I did not test it very in depth yet, so be a little
careful, though I do not expect many bugs. Once I did more testing
I'll submit the patch upstream as well, if you don't object. Also
I need to clarify some minor i18n details (cf. FIXMEs in the attached
patches) which will trigger minor updates of the patches.

First config.c gets a runtime detection. I attached a patch which
applies after the debianization has happened. config.h is a simple
file with all supported locales (two letter language code). 

debian/rules essentially only needs a one line call to a shell script
install-i18n, which copies all xpms into asclock-themes. This is
required, as this script has to map the long names used in the
orig.tar.gz (e.g. "danish") to the corresponding two letter code (e.g.
"dk"). 

I suggest a note in NEWS or README.debian. For the changelog entry,
something along the lines 
asclock (2.0.12-8.3) unstable; urgency=low

  * Enable default language selection at run time - currently 
    breton, dutch, german, indonesian, norwegian, slovene, ukrainian,
    czech, english, hebrew, italian, portuguese, spanish, danish,
    french, hungarian, japanese, russian and swedish
    are supported
  * Install pximaps for all languages with proper extension
  * Fix typo in debian/rules

 -- Helge Kreutzmann <[EMAIL PROTECTED]>  Tue, 08 Jan 2008 11:37:44 +0100

If you have any question regarding my patches, do not hesitate to ask.
Otherwise it would be nice if you could prepare a new version after
I've cleared the FIXMEs, possibly dealing with all the lintian
warnings as well.

Finally a quick side note: The "env" call in #457360 is not needed
(though setting the locale to "C" sure is!).
-- 
      Dr. Helge Kreutzmann                     [EMAIL PROTECTED]
           Dipl.-Phys.                   http://www.helgefjell.de/debian.php
        64bit GNU powered                     gpg signed mail preferred
           Help keep free software "libre": http://www.ffii.de/
--- config.c	2008-01-22 20:34:01.787870783 +0100
+++ /scr/mirror/twotofive/prog/asclock/I18n/config.c	2008-01-22 17:13:29.000000000 +0100
@@ -1,4 +1,5 @@
 #include "asclock.h"
+#include "config.h"
 
 extern char *Geometry;
 
@@ -96,10 +97,38 @@
   return FALSE;
 }
 
+char* getLanguageExtension()
+{
+	char* lang;
+
+	if((lang = getenv("LC_ALL")) == NULL)
+	{
+		if((lang = getenv("LC_MESSAGES")) == NULL)
+               {
+			if((lang = getenv("LANG")) == NULL)
+			{
+				lang="C";
+			}
+		}
+	}
+
+	char** local = supported_locales;
+	while(*local)
+	{
+		if(strncasecmp(*local, lang, 2) == 0)
+			return *local;
+		local++;
+	}
+
+	fprintf(stderr, "Locale %s not supported\n", lang);
+	return NULL;
+}
+
 int loadTheme(char *themesdir)
 {
   FILE *f;
   char filename[MAX_PATH_LEN];
+  char* langExt = "";
 
   char token[64];
   int type;
@@ -162,14 +191,26 @@
 
   fclose(f);
 
+  langExt = getLanguageExtension();
+
   strcpy(clock_xpm_fn, themesdir);
   strcat(clock_xpm_fn, "/clock.xpm");
 
-  strcpy(month_xpm_fn, themesdir);
-  strcat(month_xpm_fn, "/month.xpm");
+  if (langExt==NULL)
+  {
+	strcpy(month_xpm_fn, themesdir);
+	strcat(month_xpm_fn, "/month.xpm");
 
-  strcpy(weekday_xpm_fn, themesdir);
-  strcat(weekday_xpm_fn, "/weekday.xpm");
+	strcpy(weekday_xpm_fn, themesdir);
+	strcat(weekday_xpm_fn, "/weekday.xpm");
+  }
+  else
+  {
+	sprintf(month_xpm_fn,   "%s%s%s%s", themesdir, "/month.",   langExt, ".xpm");
+	printf("Opening:%s\n",month_xpm_fn);
+	sprintf(weekday_xpm_fn, "%s%s%s%s", themesdir, "/weekday.", langExt, ".xpm");
+	printf("Opening:%s\n",weekday_xpm_fn);
+  }
 
   strcpy(date_xpm_fn, themesdir);
   strcat(date_xpm_fn, "/date.xpm");
char *supported_locales[]={ "br", "cz", "de", "dk", "en", "es", "fr", "he", "hu", "id", "jp", "nb", "it", "nl", "pt", "ru", "sl", "sv", "uk", NULL };

--- debian/rules	2008-01-22 20:34:01.787870783 +0100
+++ /scr/mirror/twotofive/prog/asclock/I18n/rules	2008-01-22 20:39:57.000000000 +0100
@@ -1,5 +1,5 @@
 #!/usr/bin/make -f
-# this is a -*- Makefile -*-, beleive it or not
+# this is a -*- Makefile -*-, believe it or not
 # Based on sample debhelper debian/rules. GNU copyright 1997 by Joey Hess.
 # GNU copyright 1998-2001 Marcelo Magallon
 
@@ -38,6 +38,7 @@
 	( cd themes && tar cf - $$(find \( -name CVS -o -name themes \) -prune -o \! -type d -print) ) | ( cd debian/asclock-themes/usr/share/asclock && tar xf - )
 # The upstream tarball contains some cruft.
 	find debian/asclock-themes/usr/share/asclock -type f -name classic | xargs rm
+	debian/install-i18n
 	dh_installdocs
 	dh_installchangelogs
 	dh_strip
#!/bin/bash

cd languages

for i in *; do
    wfile="$i/weekday.xpm"
    mfile="$i/month.xpm"
    ext="XX"
    case $i in
        breton) 
            ext="br"
            ;;
        czech) 
            ext="cz"
            ;;
        danish) 
            ext="dk"
            ;;
        dutch) 
            ext="nl"
            ;;
        english) 
            ext="en"
            ;;
        french) 
            ext="fr"   # FIXME Which one?
            ;;
        german) 
            ext="de"
            ;;
        hebrew) 
            ext="he"
            ;;
        hungarian) 
            ext="hu"
            ;;
        indonesian) 
            ext="id"
            ;;
        italian) 
            ext="it"
            ;;
        japanese) 
            ext="jp"
            ;;
        norwegian) 
            ext="nb"    # FIXME nn or nb
            ;;
        portuguese) 
            ext="pt"
            ;;
        russian) 
            ext="ru"
            ;;
        slovene) 
            ext="sl"
            ;;
        spanish) 
            ext="es"
            ;;
        swedish) 
            ext="sv"
            ;;
        ukrainian) 
            ext="uk"
            ;;
    esac
    if [ x$ext == "xXX" ]; then
        echo "Unknown language: $i"
        exit 1
    fi
    for j in ../debian/asclock-themes/usr/share/asclock/*; do
        cp -ip $wfile $j/weekday.${ext}.xpm
        cp -ip $mfile $j/month.${ext}.xpm
    done
done

cd -

Attachment: signature.asc
Description: Digital signature

Reply via email to