Synch up with liece-2_0.
[elisp/liece.git] / lisp / gettext.el
index 0051437..5e9cbe9 100644 (file)
@@ -244,10 +244,31 @@ Return the list of results."
 Here's how the path to message files is constructed under SunOS 5.0:
   {pathname}/{LANG}/LC_MESSAGES/{domain}.mo
 \[XEmacs I18N level 3 emulating function]"
-    (let* ((lang (getenv "LANG"))
+    (let* ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") (getenv "LANG")))
+          (language (progn
+                      (string-match "\\([^_.]+\\)\\(_[^.]+\\)?\\(\\.[^@]+\\)?"
+                                    lang)
+                      (match-string 1 lang)))
+          (territory (match-string 2 lang))
+          (code-set (match-string 3 lang))
+          (lang-path (if lang
+                         (delq nil (list (if (and territory code-set)
+                                             (concat language territory
+                                                     code-set))
+                                         (if territory
+                                             (concat language territory))
+                                         (if code-set
+                                             (concat language code-set))
+                                         language))))
           (file (concat domain ".mo"))
-          (catalog (expand-file-name
-                    file (concat pathname "/" lang "/LC_MESSAGES"))))
+          catalog)
+      (while (and (setq lang (car lang-path))
+                 (setq catalog
+                       (expand-file-name file
+                                         (concat pathname
+                                                 "/" lang "/LC_MESSAGES")))
+                 (not (file-exists-p catalog)))
+       (setq lang-path (cdr lang-path)))
       (when (file-exists-p catalog)
        ;;(file-exists-p (setq catalog (expand-file-name file pathname)))
        (push (cons domain catalog) gettext-message-domain-to-catalog-alist))))