diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-13 11:13:33 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-13 11:13:33 +0000 |
| commit | 7e960384fa89c02c2fc2be1f61fe18645f8a13fe (patch) | |
| tree | 66d17d5fb9a7f73a3291e6261f1df2e12612eb2e /chess-message.el | |
| parent | f4639c9095c34caa60b4122e2cf4d6b1402508e3 (diff) | |
added message catalog support
Diffstat (limited to 'chess-message.el')
| -rw-r--r-- | chess-message.el | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/chess-message.el b/chess-message.el new file mode 100644 index 0000000..79786ff --- /dev/null +++ b/chess-message.el @@ -0,0 +1,47 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Code shared by all chess displays +;; +;; $Revision$ + +(defgroup chess-message nil + "Support for message catalogs in chess.el." + :group 'chess) + +(defcustom chess-message-language 'english + "The language to use when reporting messages." + :type 'symbol + :group 'chess-message) + +;;; Code: + +(defvar chess-message-catalog nil) + +(defun chess-message-catalog (catalog definitions) + (let ((entry (assq catalog chess-message-catalog))) + (if entry + (dolist (def definitions) + (let ((str (assq (car def) (cdr entry)))) + (if str + (setcdr str (cdr def)) + (push def (cdr entry))))) + (push (cons catalog definitions) chess-message-catalog)))) + +(defun chess-string (key &rest arguments) + (let* ((entry (assq chess-message-language chess-message-catalog)) + (msg (and entry (cdr (assq key (cdr entry)))))) + (if msg + (apply 'format msg arguments) + "message not found"))) + +(defsubst chess-message (key &rest arguments) + (message (apply 'chess-string key arguments))) + +(defsubst chess-error (key &rest arguments) + (error (apply 'chess-string key arguments))) + +(put 'chess-message-catalog 'lisp-indent-function 1) + +(provide 'chess-message) + +;;; chess-message.el ends here |
