Update.
[elisp/gnus.git-] / lisp / gnus-i18n.el
1 ;;; gnus-i18n.el --- Internationalization for Gnus
2
3 ;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1997/11/27
7 ;; Keywords: internationalization, news, mail
8
9 ;; This file is not part of GNU Emacs yet.
10
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Code:
27
28 ;;; @ newsgroup default charset
29 ;;;
30
31 (defvar gnus-newsgroup-default-charset-alist
32   '(("^\\(fj\\|tnn\\|japan\\)\\."       . iso-2022-jp-2)
33     ("^han\\."                          . euc-kr)
34     ("^relcom\\."                       . koi8-r)
35     ("^alt\\.chinese\\.text\\.big5"     . cn-big5)
36     ("^hk\\(star\\)?\\."                . cn-big5)
37     ("^tw\\."                           . cn-big5)
38     ("^alt\\.chinese"                   . hz-gb-2312)
39     )
40   "Alist of newsgroup patterns vs. corresponding default MIME charset.
41 Each element looks like (REGEXP . SYMBOL).  REGEXP is pattern for
42 newsgroup name.  SYMBOL is MIME charset or coding-system.")
43
44 (defun gnus-set-newsgroup-default-charset (newsgroup charset)
45   "Set CHARSET for the NEWSGROUP as default MIME charset."
46   (let* ((ng-regexp (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)"))
47          (pair (assoc ng-regexp gnus-newsgroup-default-charset-alist)))
48     (if pair
49         (setcdr pair charset)
50       (setq gnus-newsgroup-default-charset-alist
51             (cons (cons ng-regexp charset)
52                   gnus-newsgroup-default-charset-alist)))))
53
54
55 ;;; @ localization
56 ;;;
57
58 (defun gnus-set-summary-default-charset ()
59   "Set up `default-mime-charset' of summary buffer.
60 It is specified by variable `gnus-newsgroup-default-charset-alist'
61 \(cf. function `gnus-set-newsgroup-default-charset')."
62   (if (buffer-live-p gnus-summary-buffer)
63       (let ((charset
64              (catch 'found
65                (let ((group
66                       (save-excursion
67                         (set-buffer gnus-summary-buffer)
68                         gnus-newsgroup-name))
69                      (alist gnus-newsgroup-default-charset-alist))
70                  (while alist
71                    (let ((pair (car alist)))
72                      (if (string-match (car pair) group)
73                          (throw 'found (cdr pair))
74                        ))
75                    (setq alist (cdr alist)))
76                  ))))
77         (if charset
78             (progn
79               (save-excursion
80                 (set-buffer gnus-summary-buffer)
81                 (make-local-variable 'default-mime-charset)
82                 (setq default-mime-charset charset))
83               (make-local-variable 'default-mime-charset)
84               (setq default-mime-charset charset))
85           (kill-local-variable 'default-mime-charset)))))
86
87
88 ;;; @ end
89 ;;;
90
91 (provide 'gnus-i18n)
92
93 ;;; gnus-i18n.el ends here