[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Woman path : adding l10n man pages
From: |
Glenn Morris |
Subject: |
Re: Woman path : adding l10n man pages |
Date: |
Mon, 04 Feb 2008 14:58:34 -0500 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Andreas Schwab wrote:
> LANG can also contain a language alias. There is no requirement that
> the first two character have anything to do with the language code.
> Moreover, the language should actually be derived from LC_MESSAGES.
Please try this patch. I have no idea if `woman-expand-locale' is
returning a sensible list of alternatives.
Index: mule-cmds.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/international/mule-cmds.el,v
retrieving revision 1.320
diff -c -c -w -r1.320 mule-cmds.el
*** mule-cmds.el 1 Feb 2008 16:01:17 -0000 1.320
--- mule-cmds.el 4 Feb 2008 19:51:39 -0000
***************
*** 2422,2427 ****
--- 2422,2440 ----
;; too, for setting things such as calendar holidays, ps-print paper
;; size, spelling dictionary.
+ (defun locale-translate (locale)
+ "Expand LOCALE according to `locale-translation-file-name', if possible.
+ For example, translate \"swedish\" into \"sv_SE.ISO8859-1\"."
+ (if locale-translation-file-name
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (insert-file-contents locale-translation-file-name)
+ (if (re-search-forward
+ (concat "^" (regexp-quote locale) ":?[ \t]+") nil t)
+ (buffer-substring (point) (line-end-position))
+ locale))
+ locale))
+
(defun set-locale-environment (&optional locale-name frame)
"Set up multi-lingual environment for using LOCALE-NAME.
This sets the language environment, the coding system priority,
***************
*** 2491,2506 ****
(setq locale mac-system-locale))
(when locale
!
! ;; Translate "swedish" into "sv_SE.ISO8859-1", and so on,
! ;; using the translation file that many systems have.
! (when locale-translation-file-name
! (with-temp-buffer
! (set-buffer-multibyte nil)
! (insert-file-contents locale-translation-file-name)
! (when (re-search-forward
! (concat "^" (regexp-quote locale) ":?[ \t]+") nil t)
! (setq locale (buffer-substring (point) (line-end-position))))))
;; Leave the system locales alone if the caller did not specify
;; an explicit locale name, as their defaults are set from
--- 2504,2510 ----
(setq locale mac-system-locale))
(when locale
! (setq locale (locale-translate locale))
;; Leave the system locales alone if the caller did not specify
;; an explicit locale name, as their defaults are set from
***************
*** 2508,2515 ****
;; want to set them to the same value as LC_CTYPE.
(when locale-name
(setq system-messages-locale locale)
! (setq system-time-locale locale))
(setq locale (downcase locale))
(let ((language-name
--- 2512,2527 ----
;; want to set them to the same value as LC_CTYPE.
(when locale-name
(setq system-messages-locale locale)
! (setq system-time-locale locale)))
!
! (setq woman-locale
! (or system-messages-locale
! (let ((msglocale (getenv "LC_MESSAGES")))
! (if (zerop (length msglocale))
! locale
! (locale-translate msglocale)))))
+ (when locale
(setq locale (downcase locale))
(let ((language-name
Index: woman.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/woman.el,v
retrieving revision 1.67
diff -c -c -w -r1.67 woman.el
*** woman.el 12 Jan 2008 23:21:13 -0000 1.67
--- woman.el 4 Feb 2008 19:56:37 -0000
***************
*** 603,610 ****
(setq path (cdr path)))
(nreverse manpath)))
(defcustom woman-manpath
! (or (woman-parse-colon-path (getenv "MANPATH"))
'("/usr/man" "/usr/share/man" "/usr/local/man"))
"List of DIRECTORY TREES to search for UN*X manual files.
Each element should be the name of a directory that contains
--- 603,661 ----
(setq path (cdr path)))
(nreverse manpath)))
+ ;;;###autoload
+ (defcustom woman-locale nil
+ "String specifying a manual page locale, or nil.
+ If a manual page is available in the specified locale, it will be
+ offered in preference to the default version. Normally,
+ `set-locale-environment' sets this at startup."
+ :type '(choice string (const nil))
+ :group 'woman-interface
+ :version "23.1")
+
+ (defun woman-expand-locale (locale)
+ "Expand a locale into a list suitable for man page lookup.
+ Expands a locale of the form LANGUAGE_TERRITORY.CHARSET into the list:
+ LANGUAGE_TERRITORY.CHARSET LANGUAGE_TERRITORY LANGUAGE.CHARSET LANGUAGE.
+ The TERRITORY and CHARSET portions may be absent."
+ (string-match "\\([^._]*\\)\\(_[^.]*\\)?\\(\\..*\\)?" locale)
+ (let ((lang (match-string 1 locale))
+ (terr (match-string 2 locale))
+ (charset (match-string 3 locale)))
+ (delq nil (list locale
+ (and charset terr (concat lang terr))
+ (and charset terr (concat lang charset))
+ (if (or charset terr) lang)))))
+
+ (defun woman-manpath-add-locales (manpath)
+ "Add locale-specific subdirectories to the elements of MANPATH.
+ MANPATH is a list of the form of `woman-manpath'. Returns a list
+ with those locale-specific subdirectories specified by the action
+ of `woman-expand-locale' on `woman-locale' added, where they exist."
+ (if (zerop (length woman-locale))
+ manpath
+ (let ((subdirs (woman-expand-locale woman-locale))
+ lst dir)
+ (dolist (elem manpath (nreverse lst))
+ (dolist (sub subdirs)
+ (when (file-directory-p
+ (setq dir
+ ;; Use f-n-a-d because parse-colon-path does.
+ (file-name-as-directory
+ (expand-file-name sub (substitute-in-file-name
+ (if (consp elem)
+ (cdr elem)
+ elem))))))
+ (add-to-list 'lst (if (consp elem)
+ (cons (car elem) dir)
+ dir))))
+ ;; Non-locale-specific has lowest precedence.
+ (add-to-list 'lst elem)))))
+
(defcustom woman-manpath
! ;; Locales could be added in woman-expand-directory-path.
! (or (woman-manpath-add-locales
! (woman-parse-colon-path (getenv "MANPATH")))
'("/usr/man" "/usr/share/man" "/usr/local/man"))
"List of DIRECTORY TREES to search for UN*X manual files.
Each element should be the name of a directory that contains
- Re: Woman path : adding l10n man pages,
Glenn Morris <=
- Re: Woman path : adding l10n man pages, Frédéric Perrin, 2008/02/16
- Re: Woman path : adding l10n man pages, Glenn Morris, 2008/02/16
- Re: Woman path : adding l10n man pages, Juri Linkov, 2008/02/16
- Re: Woman path : adding l10n man pages, Glenn Morris, 2008/02/16
- Re: Woman path : adding l10n man pages, Juri Linkov, 2008/02/16
- Re: Woman path : adding l10n man pages, Glenn Morris, 2008/02/17
- Re: Woman path : adding l10n man pages, Juri Linkov, 2008/02/17
- Re: Woman path : adding l10n man pages, Glenn Morris, 2008/02/17
- Re: Woman path : adding l10n man pages, Juri Linkov, 2008/02/17
- Re: Woman path : adding l10n man pages, Miles Bader, 2008/02/17