Function: get-locale-names
get-locale-names is a byte-compiled function defined in
mule-cmds.el.gz.
Signature
(get-locale-names)
Documentation
Return a list of locale names.
Probably introduced at or before Emacs version 28.1.
Source Code
;; Defined in /usr/src/emacs/lisp/international/mule-cmds.el.gz
(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))
(delete-dups (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))))))