'cp278' for 'ibm278'). There are also new charsets 'ibm2xx' to
support these coding-systems.
+---
+** New function 'get-locale-names'.
+This utility function returns a list of locale names on the current
+system.
+
---
** 'while-no-input-ignore-events' accepts more special events.
The special events 'dbus-event' and 'file-notify' are now ignored in
(declare-function w32-get-console-codepage "w32proc.c" ())
(declare-function w32-get-console-output-codepage "w32proc.c" ())
+(defun get-locale-names ()
+ "Return a list of locale names."
+ (cond
+ ;; On Windows we have a built-in method to get the names.
+ ((and (fboundp 'w32-get-locale-info)
+ (fboundp 'w32-get-valid-locale-ids))
+ (mapcar #'w32-get-locale-info (w32-get-valid-locale-ids)))
+ ;; Unix-ey hosts should have a command to output locales currently
+ ;; defined by the OS.
+ ((executable-find "locale")
+ (split-string (shell-command-to-string "locale -a")))
+ ;; Fall back on the list of all defined locales.
+ ((and locale-translation-file-name
+ (file-exists-p locale-translation-file-name))
+ (with-temp-buffer
+ (insert-file-contents locale-translation-file-name)
+ (let ((locales nil))
+ (while (not (eobp))
+ (unless (looking-at-p "#")
+ (push (cadr (split-string (buffer-substring
+ (point) (line-end-position))))
+ locales))
+ (forward-line 1))
+ (nreverse locales))))))
+
(defun locale-translate (locale)
"Expand LOCALE according to `locale-translation-file-name', if possible.
For example, translate \"swedish\" into \"sv_SE.ISO8859-1\"."
See also `locale-charset-language-names', `locale-language-names',
`locale-preferred-coding-systems' and `locale-coding-system'."
- (interactive "sSet environment for locale: ")
-
+ (interactive (list (completing-read "Set environment for locale: "
+ (get-locale-names))))
;; Do this at runtime for the sake of binaries possibly transported
;; to a system without X.
(setq locale-translation-file-name