File icewm-LANG.menu.patch of Package icewm-lite

--- icewm-orig/src/yapp.cc	2004-05-23 08:18:19.000000000 +0200
+++ icewm-1.2.14/src/yapp.cc	2004-08-05 13:56:31.000000000 +0200
@@ -61,23 +61,68 @@
     return findConfigFile(name, R_OK);
 }
 
+static char *access_ok(char *name, int n_locale_suffixes, char **locale_suffixes, int mode)
+{
+     int i;
+     char *p;
+     for(i=0; i<n_locale_suffixes-1; i++) {
+        p = strJoin(name, ".", locale_suffixes[i], NULL);
+         if (access(p, mode) == 0) {
+             delete name;
+              return p;
+        }
+        delete p;
+     }
+     if (access(name, mode) == 0) return name;
+     delete name;
+     return 0;
+}
+
+#include <locale.h>
+#include <string.h>
+
 char *YApplication::findConfigFile(const char *name, int mode) {
     char *p;
+    static char *locale_suffixes[3];
+    static int n_locale_suffixes = -1;
+    static char *locale;
+    if (n_locale_suffixes < 0) {
+	locale = setlocale(LC_MESSAGES, NULL);
+	n_locale_suffixes = 0;
+       if (strcmp(locale, "C") && strcmp(locale, "POSIX")) {
+           locale = strdup(locale);
+           p = strchr(locale, '@');
+           if (p) {
+               *p = 0;
+           }
+           p = strchr (locale, '.');
+           if (p) {
+               locale_suffixes[n_locale_suffixes++] = strdup(locale);
+               *p = 0;
+           }
+           p = strchr(locale, '_');
+           if (p) {
+               locale_suffixes[n_locale_suffixes++] = strdup(locale);
+               *p = 0;
+           }
+           locale_suffixes[n_locale_suffixes++] = strdup(locale);
+       }
+    }
 
     if (name[0] == '/')
         return newstr(name);
 
     p = strJoin(getPrivConfDir(), "/", name, NULL);
-    if (access(p, mode) == 0) return p;
-    delete[] p;
+    p = access_ok(p, n_locale_suffixes, locale_suffixes, mode);
+    if (p) return p;    
 
     p = strJoin(configDir, "/", name, NULL);
-    if (access(p, mode) == 0) return p;
-    delete[] p;
+    p = access_ok(p, n_locale_suffixes, locale_suffixes, mode);
+    if (p) return p;
 
     p = strJoin(REDIR_ROOT(libDir), "/", name, NULL);
-    if (access(p, mode) == 0) return p;
-    delete[] p;
+    p = access_ok(p, n_locale_suffixes, locale_suffixes, mode);
+    if (p) return p;
 
     return 0;
 }